OPEN-SOURCE SCRIPT
Updated Index Line on Chart With Top/Bottom Margins (MarketSurge)

Adds an index line to the chart, along with configurable top/bottom margins. MarketSurge has the line in the top third/quarter of the chart area.
This script is unfortunately quite slow/laggy when zooming/scrolling. Unfortunately that is unavoidable, because to scale the visible portion of the index line it needs to access `left_visible_bar_time` and `right_visible_bar_time`. There are two issues with that. First, if a script access those variables, then it is reloaded on every zoom/scroll. So every time the chart is zoomed/scrolled, this script is reloaded and has to recalculate and draw everything from scratch. Second, TradingView has a couple of seconds delay built in before it will initiate the reload, presumably to allow the zoom/scroll to settle, and to avoid reloading on every zoom/scroll intermediate step. But that makes this script even less responsive, of course.
Tip: when using this indicator, you may also want to change the main chart's top margin to push the main plot down a bit (that setting does not affect the position of this indicator). See the "Margins" section in the Chart Setting's "Canvas" tab.
This script is unfortunately quite slow/laggy when zooming/scrolling. Unfortunately that is unavoidable, because to scale the visible portion of the index line it needs to access `left_visible_bar_time` and `right_visible_bar_time`. There are two issues with that. First, if a script access those variables, then it is reloaded on every zoom/scroll. So every time the chart is zoomed/scrolled, this script is reloaded and has to recalculate and draw everything from scratch. Second, TradingView has a couple of seconds delay built in before it will initiate the reload, presumably to allow the zoom/scroll to settle, and to avoid reloading on every zoom/scroll intermediate step. But that makes this script even less responsive, of course.
Tip: when using this indicator, you may also want to change the main chart's top margin to push the main plot down a bit (that setting does not affect the position of this indicator). See the "Margins" section in the Chart Setting's "Canvas" tab.
Release Notes
Change the default color of the line so it is visible on both dark and light themed TradingView.Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.