I am developing an indicator and I would like the calculation to start (reset) at the oldest bar of the data that is loaded.
To keep it simple for the sake of the example, let's say the indicator just starts at zero and adds the volume of each consecutive day to a running total.
So, for example:
if "oldest_bar_of_series":
CummVolume = 0;
else:
start adding
Two questions:
1 - Say I load 10, 15, 30, 45 or 100 days of data in my chart, how can access the last, oldest bar in the series so that I set the starting value to 0 based on this oldest bar?
2 - Secondly, say I've loaded 100 days of data (could be 1m, 5m, 30m, 60, etc chart... whatever timeframe) but I wanted to "reset" the indicator on the last X days. So X being 10, the cumulative sum would reset at "day 90". How can I accomplish this via Ninjascript?
Thank you kindly!

Comment