So I'm trying to get data from a secondary dataseries, week, and minutes.
I'm using the primary dataseries as 15 minutes.
The problem occurs when accessing the weekly dataseries, with a barsago value >= 2.......
the log tells me : Error on calling 'OnBarUpdate' method on bar 229: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
However, I have expanded days to load to 100, and infinite on the max bars lookback, so I don't know what's going!
I have attached what's working, and what isn't.
The problem is your above check. It doesn't prevent your code from trying to access bars that yet don't exist at the time of the first non-return. E.g.: You are trying to access 2 weeks back
before your index provides 2 weekly bars back. Your CurrentBars might be >0 but that doesn't
ensure that the weekly index is >=2.
So in order to avoid that rookie fault: Access doesn't only depend on history which provides the theoretical possibility of reaching the correct state at all. Particularly your logics must make
sure that at the point of access there is a sufficient number of bars.
It is helpful for most beginners to read the NT sections how bars develop, since the logical fault
of your code is really very basic.
Last edited by choke35; October 3rd, 2016 at 07:27 AM.
The following user says Thank You to choke35 for this post:
Try that instead. i.e. I'm checking for at least 3 bars to exist on all of the 3 data series before I can safely access any of them with subscripts ,  or .
As @choke35 said, it's a question of whether the bars exist at all yet, effectively the series get going independently. [NB I am assuming 8 behaves similarly to 7 in this respect.]
Just vary the number of bars checked for, depending on your worst-case subscript. In this case I've set them all the same for simplicity. Since many bars will never be seen on screen the 'tightness' of the check is quite arbitrary really, so long as it is safe.
The following 2 users say Thank You to ratfink for this post: