Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bug: multi-timeframe strategy non-primary bar is off by one

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Bug: multi-timeframe strategy non-primary bar is off by one

    Firstly, I have read the "multi-timeframe and instruments" section of the manual and understand the behavior described. Even though I understand the behavior as documented, I don't understand why you took the trouble to make the real-time behavior and historical data behavior different when CalculateOnBarClose = true. The real-time behavior of course makes sense; if my primary bar is 30 minutes and the secondary bar is 1 day, I of course do not know the HLC until the end of the day, when the HLC of the last 30 minute bar is also decided. It's quite baffling then why NT developers chose not to preserve the same behavior when testing with historical data; it would seem that they had to do MORE work to introduce this discrepancy.

    RFE: Please make the historical bar behavior be the same in both RT and historical case.

    Now for the bug: please see the attached picture, where I draw a black horizontal line at the High[0] and Low[0] of the daily bars using

    DrawLine(CurrentBar.ToString() + "High", 0, High[0], 13, High[0], Color.Black)

    for example. Do you notice that the High[0] and Low[0] are actually drawn on the *previous* day, starting at the closing 30 minutes of the *previous* day? It would seem that when testing with historical data, the day bar is decided at the close of previous day when 30 minute bar is the primary bar. Aside from violating causality (causing my strategy to be fantastically successful against historical data), this behavior is different than your documentation.

    Can you please point out my misunderstanding?

    -Henry
    Attached Files

    #2
    Hi henry.omd,

    The discrepency is necessary henry.omd and it is not possible to make backtesting behavior the same as real-time behavior. Please take a look at the figures here (http://www.ninjatrader-support.com/H...truments.html). Pay attention to the shaded bar. If the backtest performed like it did in real-time (Figure 2) you would be coding against a bars series object in the future. This is not possible because we can't peak into the future. On the shaded bar if we had a condition like if the secondary bars object's high is greater than x then do something. This would be looking at the high that we don't shouldn't know yet at that point in time. Does that make sense?

    The DrawLine is working as expected. You started drawing the line at the latest bar of the moment and drew the line back 13 bars. If you want to draw the line forward you want to use -13 instead of 13.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    602 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    347 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    559 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    559 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X