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
CurrentBars disparity when using multiple data series
Collapse
X
-
CurrentBars disparity when using multiple data series
When I have 2 data series in a strategy with the same time frame of bars (ES 5-minute bars and NQ 5-minute bars in this example), I get a strange result where the CurrentBars of each data series differ, sometimes by 1 bar and sometimes by 2 bars. I've illustrated this in the attachment which shows the output of a simple script that prints the data series name and that data series CurrentBars number on each OnBarUpdate. You can see that in the beginning, these 2 data series differ by 2 bars, then 1 bar, then occasionally 2 bars again (i have read that the currentbars number will start at -1 until all data series have processed, but this wouldnt explain the discrepancy of 2 bars anyway, so must be something else at play here). Each data series should increment by 1 bar on each bar update, however the 2nd data series seems to sometimes not increment at all, and at other times increment by 2. Is there a way to correct this behavior? A way to sync the data series to reliably increment and perhaps have the same CurrentBars number? Thanks in advance...Tags: None
-
Hello pkr75,
That is correct behavior because you are using two different instruments. They are not synced in who trades each instrument so they will have varied times when data comes in to close bars. You would only be able to sync the same instrument on different timeframes, in that case there is an order to which OnBarUpdate is called. For separate instruments you may see that one trades more than the other so there is no reason they should be in sync.
JesseNinjaTrader Customer Service
-
Thank you for your reply Jesse, but I am still a bit confused. Both instruments are 5 minute bars, so each instrument's bar should close every 5 minutes, right? Since I am not dealing in ticks, why should it matter if one instrument trades more than the other? Why would each instruments CurrentBars count not incrementally update every five minutes in this case?
Comment
-
You said "that depends when each instrument gets data to close the bar". What does that mean exactly? If a given instrument is synced to the time, then a 1-minute bar, for example, would close when one minute ends and the next one begins when the clock reads XX:00. But it seems like you are saying that it does not solely depend on time, because you say that an instrument needs to get some type of data in order to close the bar. Can you please explain this to me? What data is needed to close the bar? Thanks for your patience.
Comment
-
Jesse, I actually just found a reply of yours to a 2014 post which was super helpful ( https://ninjatrader.com/support/foru...cundary-series ). I'll use IsFirstTickOfBar in conjunction with BarsInProgress to do my checks before proceeding in the script. Thanks so much!
Comment
-
Originally posted by pkr75 View PostWhen I have 2 data series in a strategy with the same time frame of bars (ES 5-minute bars and NQ 5-minute bars in this example), I get a strange result where the CurrentBars of each data series differ, sometimes by 1 bar and sometimes by 2 bars. I've illustrated this in the attachment which shows the output of a simple script that prints the data series name and that data series CurrentBars number on each OnBarUpdate. You can see that in the beginning, these 2 data series differ by 2 bars, then 1 bar, then occasionally 2 bars again (i have read that the currentbars number will start at -1 until all data series have processed, but this wouldnt explain the discrepancy of 2 bars anyway, so must be something else at play here). Each data series should increment by 1 bar on each bar update, however the 2nd data series seems to sometimes not increment at all, and at other times increment by 2. Is there a way to correct this behavior? A way to sync the data series to reliably increment and perhaps have the same CurrentBars number? Thanks in advance...
Comment
-
That makes sense RJay, and thanks for your response. In my particular case, it turned out that the discrepancies occured when my script performed an action immediately after one data series had received its first tick but the other data series had not. Therefore the data series which had received its first tick closed the previous bar and updated its CurrentBars number, while the data series which had not received its first tick had not yet closed the previous bar and consequently not yet moved forward to the next CurrentBars number.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by DavidHP, Today, 07:56 AM
|
1 response
5 views
0 likes
|
Last Post Today, 08:16 AM | ||
Started by kujista, Today, 06:23 AM
|
3 responses
9 views
0 likes
|
Last Post
by kujista
Today, 08:15 AM
|
||
Started by Mindset, Yesterday, 02:04 AM
|
2 responses
18 views
0 likes
|
Last Post Today, 08:15 AM | ||
Started by f.saeidi, Today, 08:03 AM
|
1 response
5 views
0 likes
|
Last Post Today, 08:15 AM | ||
Started by samish18, 04-17-2024, 08:57 AM
|
15 responses
53 views
0 likes
|
Last Post Today, 08:13 AM |
Comment