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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        61 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        148 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        98 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X