Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator OnBarUpdate triggers after Strategy OnBarUpdate

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

    Indicator OnBarUpdate triggers after Strategy OnBarUpdate

    Hi all,

    I am making my own indicator in NinjaTrader 8. The indicator draw some dots on the chart, and it is drawing correctly so far.
    I added the indicator to a strategy I am testing, and when I run the strategy I notice that the OnBarUpdate of the indicator occurs after the OnBarUpdate of the strategy. Let's say I load historic data between 01/01/2021 to 01/01/2023, what I see is that the strategy would receive OnBarUpdate from 01/01/2021 to 01/01/2023 first, once the strategy finishes processing the data, then the indicator would receive OnBarUpdate from 01/01/2021 to 01/01/2023.

    As you can imagine, I can't use the calculated values from the indicator in my strategy as the indicator hasn't process any data yet.

    Is there something obvious I am missing?


    #2
    Hi op1031, please make sure you call the Indicator's Update() method in the Strategies OnBarUpdate method:

    OnBarUpdate()
    {
    MyIndicatorInstance.Update();

    //access indicator data here.
    }

    If this does not resolve the issue, I will need you to post a reduced example that shows the issue.

    Comment


      #3
      It sounds like your indicator may be outputting a data series e.g. Series<double> but not any plots. If your indicator does not have any plots that you are accessing, NinjaTrader does not know to run OnBarUpdate() on the nested indicator and you would need to call .Update() to enforce that it gets caught up before you access your series. You can do that from the strategy, or you can add it to the accessor for the series if you want to. There is not much of a penalty for calling Update() more than once (such as from more than one accessor) because it checks if it's already up-to-date before doing that so it would exit quickly if it's already good.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #4
        Update() fixes the issue. Thank you both!

        Comment


          #5
          Glad you were able to resolve it.
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          597 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 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
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          555 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X