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

Time[0].TimeofDay is always the session end time while in Market Replay

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

    Time[0].TimeofDay is always the session end time while in Market Replay

    Time[0].TimeofDay is always the session end time while in Market Replay.
    I run an indicator with Calculate = OnPriceChange in Market Replay.
    My indicator uses the Time[0].TimeOfDay but it's wrong. It's always the session close time. I guess time stamps are not stored in the playback data?

    #2
    Hello Brillo,

    Thanks for your post.

    The data is time stamped and it would be expected to show the end of the bar time stamp in market replay (if using time based bars) or the tick time if using non time based bars.

    I've tested this with both Market replay data and historical data and the bar or tick time is always shown (Tested with 1 minute bars and Renko bars size 5) using:

    Code:
    [I]        protected override void OnBarUpdate()
            {
                Print ("state: "+State+"   Current Bar: "+CurrentBar+"  "+Time[0].TimeOfDay);
            }[/I]

    Please test with the above print statement and advise if you still see the same. If so then please provide further information about the data/bars you are testing on/with.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      After the indicator transitions to realtime I get output like this:
      state: Realtime Current Bar: 299 17:00:00
      I'm running on 1440 minute bars on ES default template. The Playback window displays the current time as 1/6/2020 4:33:22 AM. I expect the Time[0] to return the same.

      Comment


        #4
        Hello Brillo,

        Thanks for your reply.

        As you are using a 1440 minute bar, it would be expected that the bar close time (Time[0]) will be the session close time, this would be true for playback or real time.

        To get the market replay time, try this: Print ("state: "+State+" Current Bar: "+CurrentBar+" "+Cbi.Connection.PlaybackConnection.Now);

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          I see. So for testing I can use PlaybackConnection.Now and for a live realtime just use DateTime.Now.
          Is there a way to determine if the connection is playback or on a real account?

          Comment


            #6
            Hello Brillo,

            Thanks for your reply.

            Yes, here is a test for the Playback connection:

            if (Cbi.Connection.PlaybackConnection != null)
            Print ("Connected to Playback");
            else
            Print ("not connected to playback");


            Another approach would be to check the account name as Playback always connects with Playback101: https://ninjatrader.com/support/help...gy_account.htm
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CortexZenUSA, Today, 12:53 AM
            0 responses
            1 view
            0 likes
            Last Post CortexZenUSA  
            Started by CortexZenUSA, Today, 12:46 AM
            0 responses
            1 view
            0 likes
            Last Post CortexZenUSA  
            Started by usazencortex, Today, 12:43 AM
            0 responses
            5 views
            0 likes
            Last Post usazencortex  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            168 responses
            2,266 views
            0 likes
            Last Post sidlercom80  
            Started by Barry Milan, Yesterday, 10:35 PM
            3 responses
            13 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X