How do I get this value during State.Configure?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Get amount of days to load in State.Configure
Collapse
X
-
Hello Bobin,
Thanks for your question.
ChartBars.Properties.DaysBack would be the property to try, but please note that similarly with dynamically adding data series, this may not always be available when the indicator processes State.Configure.
From the Help Guide:
Warning:
Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.
As I have tested, ChartBars.Properties are not available in State.Configure. This property would be accessible in State.DataLoaded, however.
Is there something you need this for specifically in State.Configure where State.DataLoaded will not suffice?
- Likes 1
-
Hello Jim,
thank you for your answer.
I need it to calculate how many bars to load in AddDataSeries which has to be done in the State.Configure.
Alternatively I would beed to get the amount of trading hours per day. But I can not get the TradingHours in the State.Configure either.
Comment
-
Hello Bobin,
Adding data series dynamically is not fully supported, so I would not have suggestions to offer to get this detail within State.Configure. (You need information from the primary data series, and this is not available in the script yet.)
By default, additional data series are loaded to align with the primary data series. I'm not sure I follow why you need to use AddDataSeries with the barsToLoad parameter matching the what is loaded with the primary data series. If you need data to load to match what is loaded with the primary data series, why not use an AddDataSeries overload that does not have barsToLoad?
If dynamically adding data is an absolute requirement, you could maybe consider BarsRequesting the data in State.DataLoaded. This would be asynchronous, however, and would use a separate OnBarUpdate event for that specific BarsRequest. My colleague Chelsea has an example that can show how a BarsRequest could be leveraged to load data dynamically. Attached here.
Attached Files
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
646 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
367 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
107 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
569 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment