Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
When can I access an added data series in State == State.DataLoaded ?
Collapse
X
-
Hello billythekid72,
Bar data is not available until the bar data is processed in OnBarUpdate().
You can initialize an indicator in State.DataLoaded, change colors, properties, etc, but it has not yet started processing data.
To use an index [0] and get a bar value, this must be done in OnBarUpdate() where data is processed.
Leave a comment:
-
When can I access an added data series in State == State.DataLoaded ?
Hello,
I added a ^VIX data series in my code, please see below:
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Tick, 1);
AddDataSeries("^VIX", BarsPeriodType.Day, 1);
}
When I try to access the ^VIX data series in State.DataLoaded, please see below
else if (State == State.DataLoaded)
{
Print("=========================================== ===========");
Print("^VIX 10 days moving average" + EMA(BarsArray[2], 10)[0]);
Print("=========================================== ===========");
}
I got the following error message:
Strategy 'AGG6BarDailyMonthlyVIX': Error on calling the 'OnStateChange' method: Object reference not set to an instance of an object.
However, if I access the same data series in OnBarUpdate(), it worked fine. Please advise how can t I access it when data has been loaded in State.DataLoaded? Thanks
else if (BarsInProgress == 2)
{
Print("=========================================== ===========");
Print("^VIX 10 days EMA " + EMA(BarsArray[2], 10)[0]);
Print("=========================================== ===========");
}
BillyTags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
157 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
91 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
143 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
130 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
107 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Leave a comment: