Hi @fxshrat, Actually both solutions would work similarly. As checked,
x = Cum(1);
Your_Index = x - 1; // this is the bar index we are working on
_TRACEF("Index <%g>", Your_Index);
The only issue with using the EndValue function is that if a user wishes to ‘debug’ via the exploration method then the EndValue would return only the end value of the selected range (or last value if no range is selected). The ‘plain vanilla index value’ works in both the cases
Assumptions are not facts. Instead of assuming things read the manual. Generally your formula would not get/need all bars, but only required/visible bars, unless you specifically ask for all bars. To ask for all bars, as explained in the KB you need to call SetBarsRequired( sbrAll ), otherwise unless your chart is zoomed out max, you will get a ‘moving/scrolling window’ as new bars come in, old will be removed from sight and from array and your BarCount won’t change. Instead of looking on number of bars and making assumptions on number of bars, look at the last bar DateTime. You will see it changes.
The thing is that you should NOT really use SetBarsRequired.
In 99% of cases makes no sense to ask for all bars. It just slows down the execution. DO NOT DO THIS unless you have better reason than just assumptions.
The whole expectation of increasing number of bars is flawed.
You skipped important part of my response. Just as in a scrolling window INVISIBLE bars are NOT really needed. You don't see them and you don't really need them. BarCount does not matter. What counts is that NEW BARS ARE ADDED and you get NEW DATA without changing BarCount (like in FIFO queue).
Invisible bars should not bother you. You really don't need to care what happened in 1903. Re-read my previous response especially last paragraph possibly many times until it sinks.