Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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!
Please help!
I have attached what's working, and what isn't.
Can you help answer these questions from other members on NexusFi?
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.
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 [0], [1] or [2].
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 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.