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

Market replay connection - EXACTLY the same as realtime?

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

    Market replay connection - EXACTLY the same as realtime?

    NT Team,

    I've noticed critical differences in the behavior of a custom indicator between real-time and historical data. To prove I wasn't going crazy I took chart screenshots of the indicator at the end of a realtime trading day and compared them against the chart created one trading day hence (once the trading day historical data).

    As stated in the NT7 Help Guide the Market Replay Connection provides "market data to all NinjaTrader windows as if it was happening in real-time". I was hoping this facility would help me debug the custom indicator, replicating the indicator output as if it was real-time. However, this is not the case. The Market Reply Connection chart presents as if it were entirely calculated on historical data.

    Is my understanding of the Market Replay Connection incorrect?
    Any pearls of wisdom on how I might debug this indicator, outside of composing the indicator to write extensively to the Output window and then comparing the realtime and historical outputs of trading days as time rolls forwards?

    As always, any insight would be appreciated.
    Regards
    Shannon

    #2
    Hi Shannon, did you actually run the indicator calcs in Market Replay going the day forward through the recorded / downloaded dataset or did you calculated the indicator values simply on the historical chart data being connected to Market Replay? This would be a critical difference here.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,

      Thanks for the reply.

      I'm not quite sure I understand. The sequence I followed:
      1. Load the Workspace containing the 15min chart in question (the chart contains the the offending indicator)
      2. Connect to Market Replay Connection
      3. Set the start (aka "From") date in the Market Replay Connection window (the End date in the chart data series window is then greyed out to the day immediately prior to the Market Replay Connection start date.
      4. Start the Market Replay (and speed up considerably). The chart in question begins to move through time.
      5. The indicator calculates like it is based on historical data (where I expect it calculate like it was based on real-time data). As noted previously the indicator behaves differently in real-time vs historical.

      I am unsure how this process fits into your explanation. Any guidance would be appreciated.

      Interestingly, in the custom indicator script there is no if(Historical) or similar. I can not think of why it behaves differently. The custom indictor does use if(FirstTickOfBar) but that's about it from an execution perspective.

      Thanks again
      Shannon

      Comment


        #4
        Thanks Shannon, that would be right process wise - I just thought you loaded it on a historical chart being connected to Market Replay but without actually replaying the day at all, so this is out of the way as potential reason for the discrepancies seen here. Are you relying on any logic that would need the realtime pc clock .ticks for subsecond timestamp access? Does it matter at which speed the day is replayed?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          you should read well Bertrands comments.
          If your indicator uses some sort of realtime clock (DateTime.Now) then in MarketReplay it will behave differently.

          @Bertrand: You could expose a ReplayWindow.Now function or similar. Currently I have to read the replay windows title bar to get this information (But it is a slow method)

          regards
          Andreas

          Comment


            #6
            Bertrand & zweistein,

            The strategy in question is designed to execute in the last three seconds of each bar (in this case the last three seconds of a 15min ES bar). This is effected via the code:
            Code:
            TimeSpan barTimeLeft = Bars.Get(Bars.Count - 1).Time.Subtract(DateTime.Now);
            if (!(Historical) && !(barTimeLeft.Minutes <= 0 && barTimeLeft.Seconds < 3))
              return;
            In short, yes the strategy code does use the PC clock.

            However, the strategy accesses a particular indicator where this anomaly has presented. The indictor which is directly applied to the chart in question on the same input panel as the input series calculates OnBarUpdate. Historical bars and realtime bars are calculated OnBarUpdate, no PC clock reference is made. However, a Time[0] reference (time stamp values) is made to differentiate NYSE cash market hours from night market hours.

            I expect the strategy (which references PC clock) to be different in Market Replay than realtime. However, I expected the indicator (no PC clock reference) to be the identical in a Market Replay environment.

            Where is my understanding wrong?

            Thanks again
            Shannon

            Comment


              #7
              Shannon, sorry I'm not following you 100% here : is the indicator giving you issues in Market Replay when called from the strategy using the irrelevant PC clock reference or not? If not, then we would need to know what the indicator calcs are doing in order to better understand why you would see discrepancies here in Market Replay vs Realtime.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by traderqz, Today, 12:06 AM
              10 responses
              18 views
              0 likes
              Last Post traderqz  
              Started by algospoke, 04-17-2024, 06:40 PM
              5 responses
              46 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by arvidvanstaey, Today, 02:19 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by mmckinnm, Today, 01:34 PM
              3 responses
              5 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by f.saeidi, Today, 01:32 PM
              2 responses
              9 views
              0 likes
              Last Post f.saeidi  
              Working...
              X