Thank you.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Retreiving Candle duration / Chart timeframe
Collapse
X
-
Retreiving Candle duration / Chart timeframe
Simple question, how do you retrieve the current chart candle duration setting (i.e. 1 minute, 5 minute, 10 minute, etc.) within a script? I want to be able to adjust strategy parameters dynamically in the script if I change the candle duration of the chart manually in real time.
Thank you.Tags: None
-
Hello Dr Kerry,
The values of the barstype can be accessed while the script is running but cannot be used for the purpose of controlling user inputs in the earlier states of the script. In your OnBarUpdate logic you could certainly use those values to deleage what the strategy is doing.
To access the bars type values you can use the following values:
Code:Print(Bars.BarsPeriod.Value + " " + Bars.BarsPeriod.BarsPeriodTypeName); if(Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Minute && Bars.BarsPeriod.Value > 5)
- Likes 1
-
Jesse,
Thank you very much for your quick reply. I think that what you suggest will work because the strategy restarts whenever the candle time scale is changed manually. So it will be able to get the current chart setting and use that in combination with the "if" statements to set the parameter values accordingly.
Regards,
Kerry
Comment
-
Hello Dr Kerry,
Correct, each time you change the timeframe the strategy will restart so those will match the series that the strategy is applied to. The only time those values won't be available is during the early states of the strategy before State.DataLoaded. You can see some examples on the following page, that usage is the same as what I provided, Bars.BarsPeriod, the Bars property just refers to the primary bar series being used.
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
139 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment