Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Index Out of Range for multi-series
Collapse
X
-
I am having similar "You are accessing an index..." issues with trying to put values into a private Series, defined in State.DataLoaded clause of OnStateChanged (also tried in State.Configure)
DirectSeries = new Series<double>(this, MaximumBarsLookBack.Infinite);
The number of elements (DirectSeries.Count) value is 2727.
When I attempt to assign values starting at element 240, the error occurs:
For (int I = 240; I >=0; I--)
{
DirectSeries[I] = <a double value>;
}
This is extremely frustrating. It should be a trivial matter to put values into a private series. While I concede I must be missing something, I cannot understand why this simple code doesn't work.
-
Hi habibalex,
I'd like to assist by correcting a small sample.
Can you create a working indicator with just this code demonstrated and export this?
Tools -> Export -> NinjaScript
Leave a comment:
-
This doesn't quite fix my problem since I still need to loop through all 35000 values in Highs[1] and Lows[1]. Those values do not exist to complete the rest of the indicator's calculation. It looks like anything greater 13 bars ago does not exist in those series as well.
Leave a comment:
-
If you are calling a Series outside of a core market data handler, the current bar pointer may not be in sync, resulting in index out of range exceptions.
For any custom event methods, like when your text box changes, or a mouse down for example, you should use Absolute Indexes rather than try to find a barsAgo value. I have posted a simlar comment with some undocumented advice as well: http://ninjatrader.com/support/forum...49&postcount=2
Leave a comment:
-
Index Out of Range for multi-series
I have an indicator that runs on the last historical bar of chart data. It calls a function similar to the runMe one below and it works fine with no exceptions.
I have a textbox which when changed will call the runMe function again. All subsequent times the runMe function is run, Times[1][endI] throws an error ArgumentOutOfRangeException. Times[1].Count has 35082 members, and endI is only around 500 when the Print(Times[1][endI]) is throwing this exception. Why would this happen?
Code:private void runMe(int startI, int endI) for(int key = endI;key <= startI; key++){ if(BarsArray[1].IsFirstBarOfSessionByIndex(Times[1].Count - 1 - key)){//first bar of session endI = key ; Print(Times[1][endI]); break; } } }
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Shansen, 08-30-2019, 10:18 PM
|
24 responses
938 views
0 likes
|
Last Post
by spwizard
Today, 01:29 AM
|
||
Started by Max238, Today, 01:28 AM
|
0 responses
3 views
0 likes
|
Last Post
by Max238
Today, 01:28 AM
|
||
Started by rocketman7, Today, 01:00 AM
|
0 responses
2 views
0 likes
|
Last Post
by rocketman7
Today, 01:00 AM
|
||
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
Leave a comment: