Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate() not called

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

    OnBarUpdate() not called

    Hi,

    I've been testing and debugging the strategy with two time frames 5 min and daily. See the code below. I found out that when I add daily time frame to the main 5 min one the OnBarUpdate() is never called (for neither time frame 5 min nor daily) till the session end (17:15 for futures). Note, the code in OnBarUpdate() doesn't matter as the method is not called. I made sure there is enough historical data. Now, when I disable the second, daily time frame - problem disappears. Why?

    protected override void Initialize()
    {

    this.Days2Load = 16;
    this.BarsRequired = 8;

    Add(PeriodType.Day, 1);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick).
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (this.CurrentBars[0] < 40
    || this.CurrentBars[1] < 8)
    return; //Check if enough bars for indicators

    //...
    }

    #2
    Originally posted by corrado View Post
    Hi,

    I've been testing and debugging the strategy with two time frames 5 min and daily. See the code below. I found out that when I add daily time frame to the main 5 min one the OnBarUpdate() is never called (for neither time frame 5 min nor daily) till the session end (17:15 for futures). Note, the code in OnBarUpdate() doesn't matter as the method is not called. I made sure there is enough historical data. Now, when I disable the second, daily time frame - problem disappears. Why?

    protected override void Initialize()
    {

    this.Days2Load = 16;
    this.BarsRequired = 8;

    Add(PeriodType.Day, 1);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick).
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (this.CurrentBars[0] < 40
    || this.CurrentBars[1] < 8)
    return; //Check if enough bars for indicators

    //...
    }
    Try this, and look in the Output Window to let you know if you are cooking.
    Code:
    protected override void OnBarUpdate()
    {
    if (this.CurrentBars[0] < 40 || this.CurrentBars[1] < 8)
    {
    Print(null);
    Print("Entered the CurrentBars check block");
    Print("cb0: " + CurrentBars[0]);
    Print("cb1: " + CurrentBars[1]);
    return; //Check if enough bars for indicators
     }
    Print(null);
    Print("Now we are cooking!");
    Print("cb0: " + CurrentBars[0]);
    Print("cb1: " + CurrentBars[1]);
    //...             
     
    }
    If you are still never cooking, then look at your logs. That should tell you a story.

    Comment


      #3
      koganam,

      Thank you for trying to help. Logging in the OnBarUpdate() doesn't help here as the method is simply not called when this line added to the Initialize method:
      Add(PeriodType.Day, 1);
      No useful info in the NinjatTrader's log found.

      Comment


        #4
        Hello corrado,

        Thank you for your post.

        I will follow up with you via your e-mail to support[at]ninjatrader[dot]com.

        Comment

        Latest Posts

        Collapse

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