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 Rapine Heihei, 04-23-2024, 07:51 PM
              2 responses
              30 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by Shansen, 08-30-2019, 10:18 PM
              24 responses
              943 views
              0 likes
              Last Post spwizard  
              Started by Max238, Today, 01:28 AM
              0 responses
              9 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by rocketman7, Today, 01:00 AM
              0 responses
              7 views
              0 likes
              Last Post rocketman7  
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              28 views
              0 likes
              Last Post wzgy0920  
              Working...
              X