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

Controlling order of OnBarUpdate() calls for Multi-Time Frame script

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

    Controlling order of OnBarUpdate() calls for Multi-Time Frame script

    Hello,

    I have a strategy that must run calculations on higher time frames before running the main logic on the primary bars. However, it seems that in a multi-time frame script, the primary bars is processed first, and then other bars objects are processed according to the order they were added via AddDataSeries(). How can I control the order so that the OnBarUpdate() for the primary bars is called last?

    Thanks for your help!

    #2
    Hello deltaZ,

    There would not be a way to control OnBarUpdate to make it work differently than expected. The platform will work in a specific way when working with multi series as noted in the help guide: https://ninjatrader.com/support/help...lightsub=multi

    You would need to form your logic to accommodate how the platform works in the use case as you cannot modify how OnBarUpdate is called for multiple series. You can change the order of series that you add or the primary so if the concept is possible to execute by changing the primary series that may be one option.




    Please let me know if I may be of additional assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse.

      For those of you that also ran into the call order as a limitation, rearranging the BarsArray elements seems to work fine, such as this:
      Code:
       if (State == State.DataLoaded) {         Bars temp = BarsArray[0];     BarsArray[0] = BarsArray[BarsArray.Count() - 1];     BarsArray[BarsArray.Count() - 1] = temp; }
      Of course there is no guarantee that this works in future version of NT. If it fails to work in the future I'll get around this limitation by adding an additional dataseries via AddDataSeries() that is identical to the primary series after all other series are already added. Then I'll ignore OnBarUpdate() calls for BarsInProgress==0.

      Again, this is a limitation because I need the strategy to run on a chart built from my primary/fast bar series, but need all internal slow bar series calculated first before calculating a final signal on the primary bar series.

      Comment


        #4
        As a follow up, I ended up going with option two from my previous post, creating a duplicate primary bars series that runs at the end of all others. Modifying the BarsArray ordering creates a 1-bar order execution delay, and probably other consequences as it's indeed an extreme tinker.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jclose, Today, 09:37 PM
        0 responses
        5 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,413 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Today, 08:53 PM
        0 responses
        11 views
        0 likes
        Last Post firefoxforum12  
        Started by stafe, Today, 08:34 PM
        0 responses
        11 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by sastrades, 01-31-2024, 10:19 PM
        11 responses
        169 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X