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 judysamnt7, 03-13-2023, 09:11 AM
              4 responses
              57 views
              0 likes
              Last Post DynamicTest  
              Started by ScottWalsh, Today, 06:52 PM
              4 responses
              36 views
              0 likes
              Last Post ScottWalsh  
              Started by olisav57, Today, 07:39 PM
              0 responses
              7 views
              0 likes
              Last Post olisav57  
              Started by trilliantrader, Today, 03:01 PM
              2 responses
              19 views
              0 likes
              Last Post helpwanted  
              Started by cre8able, Today, 07:24 PM
              0 responses
              9 views
              0 likes
              Last Post cre8able  
              Working...
              X