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!
See more
See less

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 KenneGaray, Today, 03:48 AM
        0 responses
        3 views
        0 likes
        Last Post KenneGaray  
        Started by thanajo, 05-04-2021, 02:11 AM
        4 responses
        470 views
        0 likes
        Last Post tradingnasdaqprueba  
        Started by aa731, Today, 02:54 AM
        0 responses
        4 views
        0 likes
        Last Post aa731
        by aa731
         
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        10 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,237 views
        0 likes
        Last Post sidlercom80  
        Working...
        X