I am trying to make an automatic comparison to a symbol's relevant market index from Pine script. Similar to the "Compare" feature available in TradingView (see image below) - just automatically done from Pine script. For the purpose of this question you can assume that I already have code that correctly fetches the symbol of the relevant market index.
The issue I have run into is that I can't seem to figure out how many bars are actually shown in the plot. Therefore I am not able to scale the two lines from a common starting point at the start of the shown time interval. The native "Compare" feature is rescaling the lines dynamically as the plotted time interval is changed, but is it possible to do the same from Pine script?
