I am wondering if there is a way to get the number of bar
of the timeframe that my chart is in it from the beginning.
My goal is to use the final bar_index as a variable in my code, but the issue is that the bar index will increase by time. so I was wonderingwhat would be the solution here.
To explain more I am providing the example here.
Lets say I am in 2H
charts and there are in total 20K bar_index
there, if I know the 20K for the beginning, I can then provide the condition that whatever total bars that my chart will have should be divided with n
and then just apply my functions on a range of the results. but I dont know how I can know the total number of bars in the chart from the beginning...
I guess my question can also be ask as follow: can we somehow at the beginning of the code (not at the end via barstate.islast
) know what is the total number of bars in the chart based on the timeframe we are in?