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

Bar Closing Time

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

    Bar Closing Time

    Hi Ninjatrader,

    I found several threads discussing bar times (using the Time[] and Times[] array) within the OnBarUpdate event but found only answers that I didn't want to hear

    What I want might not be possible due to the mechanics of how bars are created within Ninjatrader (I read the discussion within the help files on this), however let me ask and get your response.

    What I want is to get the timestamp of the bar close (not the bar open which is given in the Time[] array). I have to use CalculateOnBarClose=True. Do you know of any way to get the closing timestamp of the last trade of the last bar instead of the opening timestamp ?

    I don't want to use local pc time, rather I want the timestamp of the trade from the price vendor. In summary, is there a workaround (using something like bartimer indicator or something) that will give me a more accurate reading of the timestamp for the last trade of the bar when OnBarUpdate=true;

    Thank you for any insight or solutions.

    Number1
    Last edited by number1; 05-13-2014, 02:44 PM.

    #2
    It is just the other way round. The Time[] and Times[] arrays hold the timestamps of the bar close. NinjaTrader does not easily allow for retrieving the opening timestamps.

    All NinjaTrader timestamps are in local time. You can easily convert them back to exchange time by using the framework that comes with the .NET framework 3.5.
    Last edited by Harry; 05-13-2014, 02:53 PM.

    Comment


      #3
      Thank you for responding. I was basing the question on a post from Ninja Support link: :http://www.ninjatrader.com/support/f...ad.php?t=56903

      "You can use Time[0] to pull the current bar's time. If you have CalculateOnBarClose set to false, then you will get the current time of the bar. If CalculateOnBarClose is set to true, then you will get the last bar's close time."

      That is telling me if CalculateOnBarClose=true you get the last bar's close time. I am confused. Thanks for any clarification.

      Comment


        #4
        Hello Number1,

        Thank you for your post and for Harry on answering the question.

        Yes, the Time[] will return the timestamp of the bar close.

        Additionally, you would need to use the conversion for the exchange's time.
        http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx


        Let me know if I can be of further assistance.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Thank you responding. Well then I have mystery on my hands which maybe you can help with.

          My PC clock time is regularly updated using a local NTP timer server and is accurate within 20-100 milliseconds. I am measuring the timestamp difference between the timestamps given in Time[] from the OnBarUpdate event and my PC clock (System.DateTime.Now).

          When the market is busy/active the difference in timestamp and pc clock is negligible (i.e. within a ping time). When the market is slow, the timestamp difference can be as high as 10 seconds.

          This is why I though it was giving me the opening time of the bar (therefore taking up to 10 seconds for the bar to complete). But you are now clarifying that when OnBarUpdate=true the Time[] will be the last trade of the bar.

          There must be something else going on causing the delay then. The big mystery is why only when the market is slow is the timestamp delay apparent (2 to 10 seconds) yet within milliseconds accurate during normal/fast markets? Thoughts?
          Last edited by number1; 05-13-2014, 03:44 PM.

          Comment


            #6
            The problem is that during a slow market a bar may be filled but is not closed until a new tick comes in and creates a new bar. At that point the bar is closed (a 1 minute bar may be 1.5 minutes long). I think this is what you are experiencing.
            eDanny
            NinjaTrader Ecosystem Vendor - Integrity Traders

            Comment


              #7
              Danny! You are so correct! Thank you. Saved me HOURS of debug and stress. Thank you again for that. Sherlock Holmes level cleverness. Have a drink on me

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by hazylizard, Today, 08:38 AM
              4 responses
              10 views
              0 likes
              Last Post hazylizard  
              Started by geddyisodin, Today, 05:20 AM
              2 responses
              18 views
              0 likes
              Last Post geddyisodin  
              Started by Max238, Today, 01:28 AM
              5 responses
              47 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by giulyko00, Yesterday, 12:03 PM
              3 responses
              13 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by habeebft, Today, 07:27 AM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_ChristopherS  
              Working...
              X