Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Force Update()

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

    Force Update()

    My indicator gets data from an Action and calls Update() after all calculations are done.
    However, Update() thinks that the bars are already uptodate and does nothing.
    How do I force Update() to actually run the OnBarUpdate() method again for all bars? Similar to ForceRefresh() for OnRender().

    #2
    Hello Bobin,

    I believe in the described use case you would want to just use a loop inside your action to do whatever calculation you needed on the existing bar data. Update is used for a parent script to tell a child to update, for example an indicator with no plots that exposes only a public bool property. If a parent script wanted the bool property to be populated for the CurrentBar then the child will have Update() inside that public property so that when the parent calls it the script runs the OnBarUpdate logic. That use case assumes that the child wasn't up to date when the parent called it (no plot being accessed) so it runs the bars. Your script is already up to date so that wont be useful for that use case.

    You would need to review what your OnBarUpdate logic is currently doing and see if that can be split into a method or if not you may need to just duplicate some of the logic inside your action and use a loop. If the action is not a NinjaScript event you may additionally need to surround the price data code inside that action with a TriggerCustomEvent: https://ninjatrader.com/support/help...ghtsub=trigger



    Comment


      #3
      Hello Jesse,
      thank you.
      I tried to iterate through all bars after State.DataLoaded, however I get an error when accessing Time[]. I debuged and found out that I can't even access Time[20] even if the CurrentBar is 50.
      I was expecting Time to be ready for every bar in this state?

      Comment


        #4
        Hello Bobin,

        Did you try that in State.DataLoaded directly or from your action? If you are trying this from OnStateChange you can't use BarsAgo, bars aren't processing yet. You can use the GetValueAt and indexes at that point, for simplicity I would suggest to use OnBarUpdate instead. The error you are seeing is expected inside your action based on the reason I provided in the last post, in the action you need to use a TriggerCustomEvent for NinjaScript series and to use BarsAgo.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        639 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        572 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X