How do I get this value during State.Configure?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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?JimNinjaTrader Customer Service
- 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 FilesJimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Option Whisperer, 05-09-2024, 07:58 PM
|
6 responses
25 views
0 likes
|
Last Post Today, 06:52 PM | ||
Started by rayyyu12, Today, 05:38 PM
|
0 responses
12 views
0 likes
|
Last Post
by rayyyu12
Today, 05:38 PM
|
||
Started by xepher101, Yesterday, 12:19 PM
|
2 responses
30 views
0 likes
|
Last Post
by xepher101
Today, 05:03 PM
|
||
Started by thumper57, Today, 04:30 PM
|
0 responses
8 views
0 likes
|
Last Post
by thumper57
Today, 04:30 PM
|
||
Started by OllieFeraher, 05-09-2024, 11:14 AM
|
5 responses
16 views
0 likes
|
Last Post
by MisterTee
Today, 03:19 PM
|
Comment