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 bortz, 11-06-2023, 08:04 AM
                  47 responses
                  1,606 views
                  0 likes
                  Last Post aligator  
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post Javierw.ok  
                  Working...
                  X