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

OnBarUpdate

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

    OnBarUpdate

    Is there a anyway to know if when OnBarUpdate is called it is from live data or historical data?

    #2
    PDT,

    Yes! This is called "Historical" and is a variable.



    Please feel free to ask us questions any time, we are happy to answer.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi Adam,

      Thanks for the prompt reply.

      I am creating an indicator that loads a second instrument with a different timeframe. Everything works great on live real time data but if the chart is reloaded and for all previous sessions it looks like the data is exactly one bar off (before) from the charts instrument.

      Any thoughts on why?

      Thanks,
      Dan

      Comment


        #4
        PDT,

        I am not sure here, could you possible post your code and/or some screen shots?

        How to take a screenshot on your smartphone, tablet, notebook or desktop computer
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Hi Adam,

          I have spent some time trying to figure out what is going on and it looks like when the main instrument is loading historical data on the chart it is only calling OnBarUpdate once at the bar close. I am using a 2000 tick chart.

          I used the BarsInProgress == 0 and printed every time that OnBarUpdate was called and the times matched the ending times of that bar.

          9/5/2012 8:29:59 AM
          9/5/2012 8:30:45 AM
          9/5/2012 8:32:11 AM
          9/5/2012 8:33:58 AM
          9/5/2012 8:35:52 AM etc.

          This is on the ES so there are lots of ticks going off in between.

          Can you explain how the historical data is processed. I assumed that it would call OnBarUpdate for each tick or change.


          Thanks,
          Dan

          Comment


            #6
            I do have CalculateOnBarClose set to False.

            Comment


              #7
              Hi Dan, for historical processing it would not matter how CalculateOnBarClose is set - it would be 'true' per default here, as the OnBarUpdate() is called for each completed bar, not for each tick (as it would be in realtime / market replay with the CalculateOnBarClose = false).
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Hi Adam,

                I am collecting data from the second intrument on a different time frame and putting it in a dataseries which matches the main instrument. With real time it works great but since the OnBarUpdate is only called at the end of the bar on Historical data the data I collected is put into the bar before when the new bar is created.

                I assume the dataseries are added to as each new bar is created. When OnBarUpdate is called for the current bar has the next bar been added to the dataseries? Is there a way to shift the data or an easy way add it to the next bar?

                Thanks,
                Dan

                Comment


                  #9
                  Hi Adam,

                  I just setup a second dataseries and handled the loading of the historical data differently so it is working fine now.

                  Thanks,
                  Dan

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by AaronKoRn, Today, 09:49 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post AaronKoRn  
                  Started by carnitron, Today, 08:42 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post carnitron  
                  Started by strategist007, Today, 07:51 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post strategist007  
                  Started by StockTrader88, 03-06-2021, 08:58 AM
                  44 responses
                  3,975 views
                  3 likes
                  Last Post jhudas88  
                  Started by rbeckmann05, Today, 06:48 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post rbeckmann05  
                  Working...
                  X