Thanks
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
What determines the secondary and tertiary bar series order?
Collapse
X
-
What determines the secondary and tertiary bar series order?
My strategy currently has 2 bar series, a 5 minute and 30 minute in that order defined in the Strategy Builder Additional Data section. When I View Code they appear in the order added in the Additional Data section. When I run the strategy I generally run it with a Base Period Value of 30, so that will be the primary series 0, and therefore the 5 minute would become series 1 (I assume). What will happen now when I add a third series for ticks? What determines the secondary and tertiary bar series order?
ThanksTags: None
-
Hello cupir2,
Thank you for the post.
The data series on the chart will always be the primary series (the 0th series). Additional series will be added in the order they are added to the script, so you are exactly correct when you say the 5 minute series will be series 1, the 30 minute will be series 2, and the newly added tick series will be series three.
If you have not already, please see this help guide page on multi-time frame scripts:
Please let me know if I can assist further.
Chris L.NinjaTrader Customer Service
-
Hi Chris,
Thanks for your reply.
So in my example were there is a 30m series defined in Additional Data and appears second , it is series 2. But the Base Period Value is set to 30 in the Strategy Analyzer, does this mean it is actually being used as 0? When I View Code, all the indicators that use the 30m data appear to be set to 2, so i am not sure what series 0 is looking at.
On the chart itself, I have two Data Series defined for the 30m and 5m series and they overlap in panel 1. When I run the strategy from the chart, the Input series is set to 30m data series.
Thanks
Comment
-
Hello cupir2,
Thanks for the reply.
If you select a 30 minute series for the period in the Strategy Analyzer, the primary series will be 30 minute bars a.k.a BarsInProgress == 0. You would need to specify for the strategy to use the secondary series. For example, this is how I would get the SMA of the secondary series:
SMA(BarsArray[1], 20)[0];
Or in the strategy builder, you would need to specify the secondary series to be used in the "Input series" of an indicator.
The reason the 30 minute series is used in the chart with the 5 minute series laid on top of it is because that was the series added to the chart first, that will always be the primary series.
Please let me know if I can assist further.Chris L.NinjaTrader Customer Service
Comment
-
Image 01 shows the three DataSeries defined as Additional Data. Below that are the indicators used throughout the strategy. In all but one indicator I am using the 30m data as seen by the use of "2". Only MCAD2 uses the 5m data identified by "1".
Image 02 shows how the strategy is defined when assigned to a chart (left green circle) and when used in the Strategy Analyzer (right green circle).
In testing and running the strategy the Base Period Value is 30 minutes which I believe makes it the primary series "0".
What are the ramifications of defining a 30m series as "2" via the Additional Data section, while also specifying the primary "0" series as 30 minutes when running and testing the strategy?
Are there special considerations to be made for the order in which additional data series are evaluated? Best practices?
If I run the strategy using 30 minutes, should I remove the 30m data series from the Additional Data section?
Comment
-
Hello cupir2,
Thanks for the reply.
I would recommend removing the additional 30-minute series to avoid redundancy. You already have the data available as the primary series. You will know what series OnBarUpdate is being called for with the BarsInProgress index context.
EX:
Code:protected override void OnBarUpdate() { if(BarsInProgress == 0) { //This code will run when OnBarUpdate is being called for the primary series } if(BarsInProgress == 1) { //This code will run when OnBarUpdate is being called for the secondary series } if(BarsInProgress == 2) { //This code will run when OnBarUpdate is being called for the tertiary series } }
The order in which they are called depends on your Calculate property. With Calculate.OnBarClose, the OnBarUpdate for each series will be called for their respective period (every 30 minutes, 5 minutes, etc). With Calculate.OnEachTick, each series will run an OnBarUpdate for each incoming tick. In historical processing, the primary series will always be called first, unless you turn on Tick Replay.
Please let me know if I can assist further.Chris L.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
43 views
0 likes
|
Last Post Today, 12:28 AM | ||
Started by f.saeidi, Today, 12:12 AM
|
0 responses
3 views
0 likes
|
Last Post
by f.saeidi
Today, 12:12 AM
|
||
Started by Conall, Today, 12:06 AM
|
0 responses
5 views
0 likes
|
Last Post
by Conall
Today, 12:06 AM
|
||
Started by proptradingshop, 03-21-2024, 09:50 AM
|
6 responses
27 views
0 likes
|
Last Post Today, 12:02 AM | ||
Started by mly916, Yesterday, 09:48 PM
|
1 response
14 views
0 likes
|
Last Post Yesterday, 11:54 PM |
Comment