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

MarketDataEventArgs.Time out of order with multiple data series

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

    MarketDataEventArgs.Time out of order with multiple data series

    Hi everyone,

    I have a question regarding the invocation behavior of the OnMarketData method for strategies that work with multiple series. When I run a test via Playback, and print in my strategy the value of the Time property of the MarketDataEventArgs event, I realize that they arrive out of order. This occurs only in the milliseconds granularity.

    For example:
    Time, Time.Ticks, Instrument
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.835, 636679060498350000, ES 09-18
    07/23/2018 01:27:29.781, 636679060497810000, CL 09-18

    In this example, the instrument event ES 09-18 arrives at the strategy before the last instrument event CL 09-18.

    Is this behavior expected? If so, what is the reason for it?

    Thanks!
    Attached Files

    #2
    Hello ViniMob,

    This would be expected behavior.

    Behind the scenes there are data threads for the instruments that are receiving data from the connection. This then feeds data to instrument consumers (scripts, charts, or anything needing data) running in different threads in intervals. Because of this there is no guaranteed order that OnMarketData will update for any instrument.

    A tip on the same subject, GetCurrentAsk() and GetCurrentBid() get an immediate snapshot of the data from the instrument thread before this is processed and delivered to instrument consumers and these will also appear out of order (ahead of) data updating in OnMarketData.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the answer!

      Comment


        #4
        Enjoying the post, I have another related question. This should be an easy one, but I am trying to understand a simple difference related to time between market replay and realtime in ninjatrader.

        I performed a simple test with this same strategy, only printing the time.Tick value of the incoming MarketDataEventArgs, running in market replay and in real time, for the same time period. I noticed that there are time differences. For example:

        realtime time.tick
        09/13/2018 05:11:58.137
        09/13/2018 05:11:58.143
        09/13/2018 05:12:01.939
        09/13/2018 05:12:21.607
        09/13/2018 05:12:31.597

        market replay time.tick
        09/13/2018 05:11:58.101
        09/13/2018 05:11:58.113
        09/13/2018 05:12:01.886
        09/13/2018 05:12:21.558
        09/13/2018 05:12:31.554


        I suppose these differences are due to the fact that they are two different data providers. That's right? But in addition, this time information represents exactly the time of what?

        Thanks!

        Comment


          #5
          Hello ViniMob,

          Thank you for your response.

          The time you are pulling for realtime is through OnBarUpdate(), correct?

          If that is the case then you are looking at the Tick update to the bar in realtime through OnBarUpdate() versus the market data type update to OnMarketData().

          If you need further detail please post your code used for this test.

          Please let me know if you have any questions.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Radano, 06-10-2021, 01:40 AM
          19 responses
          604 views
          0 likes
          Last Post Radano
          by Radano
           
          Started by KenneGaray, Today, 03:48 AM
          0 responses
          3 views
          0 likes
          Last Post KenneGaray  
          Started by thanajo, 05-04-2021, 02:11 AM
          4 responses
          470 views
          0 likes
          Last Post tradingnasdaqprueba  
          Started by aa731, Today, 02:54 AM
          0 responses
          5 views
          0 likes
          Last Post aa731
          by aa731
           
          Started by Christopher_R, Today, 12:29 AM
          0 responses
          10 views
          0 likes
          Last Post Christopher_R  
          Working...
          X