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

Can you change OnBarUpdate initial looping?

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

    Can you change OnBarUpdate initial looping?

    I have a reasonably complex calculation and iteration through the values in OnBarUpdate.

    When I first add the Indicator and click OK it takes around 30 seconds to process 30,000 or so bars. My code is executing in max 1ms (I have tested this in VS debugger under debug mode).

    It's calling OnBarUpdate for every bar with the number of bars increasing as it goes. The delay seems to be in how quickly this OnBarUpdate is called.

    Once it has done this and the live feed is runnng, OnBarUpdate is a single call with the maximum bars and the 1ms is not an issue.

    Is there any setting or option that I can use to speed up the initial add where it can be given the complete bar count instead of looping through them?

    #2
    if(Historical) return;
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      That variable doesn't appear to be available. I've also searched the online help for NT8 and nothing found for that.

      Comment


        #4
        I got it. There is a State.Historical and I can set a variable inside this.

        Thanks for the heads up though.

        Comment


          #5
          It partially works as long as there is a live feed coming in. With no live feed it does not show up at all until the next feed update.

          I've included a boolean Enable to allow historical use. Need to work on some other options.

          Comment


            #6
            Originally posted by davemclaughlin View Post
            It partially works as long as there is a live feed coming in. With no live feed it does not show up at all until the next feed update.
            Would something like this work for you?

            Code:
            If(CurrentBar < Bars.Count -2) return;


            -=Edge=-
            NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

            Comment


              #7
              Thanks, that works plus I added a setting to enable all for when running historical back tests. Not sure if you actually need this but it doesn't hurt to include it.

              Code:
              if (CurrentBar < (Bars.Count - 2) && ! historicalEnabled)

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rajendrasubedi2023, Today, 09:50 AM
              0 responses
              10 views
              0 likes
              Last Post rajendrasubedi2023  
              Started by ender_wiggum, Today, 09:50 AM
              0 responses
              4 views
              0 likes
              Last Post ender_wiggum  
              Started by bmartz, Today, 09:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by geddyisodin, Today, 05:20 AM
              3 responses
              24 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by lorem, Today, 09:18 AM
              1 response
              5 views
              0 likes
              Last Post lorem
              by lorem
               
              Working...
              X