Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is OnBarUpdate not executing additional code?

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

    Is OnBarUpdate not executing additional code?

    I'm trying to run the strategy with live data with the Sim101 account, but I can't seem to get Print("1") or anything below it to print. I see Print("Bars Required to trade not met") when I first enable the strategy, but all I see is it print zero over and over again without ever seeing it print 1. Is there something else I need to enable for live data? Everything seems to work fine when backtesting and market replay.

    Code:
    protected override void OnBarUpdate()
    {
       Print("0");
       if (CurrentBar < BarsRequiredToTrade)
          Print("Bars Required to trade not met");
          return;
       Print("1");
      if (State == State.Historical)
          Print("State is historical");
          return;
      Print("2");
    // More code below....
    }

    #2
    Disregard this question. I created a new class with a new name and started copying the code over. For some reason it worked for the new class.

    Comment


      #3
      Glad you have it working ... but for future reference, the following slightly modified code (note the "<<<<" comments) is what will make your original effort work as expected:
      Code:
      protected override void OnBarUpdate()
      {
        Print("0");
        if (CurrentBar < BarsRequiredToTrade)
        { // <<<<<<<<<<<<<<<<
          Print("Bars Required to trade not met");
          return;
        } // <<<<<<<<<<<<<<<<
        Print("1");
        if (State == State.Historical)
        { // <<<<<<<<<<<<<<<<
          Print("State is historical");
          return;
        } // <<<<<<<<<<<<<<<<
        Print("2");
        // More code below....
      }
      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X