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

Understanding MarketDataEventArgs.Time in RealTime

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

    Understanding MarketDataEventArgs.Time in RealTime

    Hello!

    What is the MarketDataEventArgs.Time representing for Ask, Bid, and Last MarketDataTypes? Is it when the data was received by the exchange?

    The reason I ask is that upon printing the times of the Ask, Bid, and Last events on live data, I observed that the timestamps are not chronological. Here is an example from today on NQ:
    Ask: 2023-10-05 10:18:40:69
    Bid: 2023-10-05 10:18:40:69
    Ask: 2023-10-05 10:18:40:72
    Bid: 2023-10-05 10:18:40:72
    Ask: 2023-10-05 10:18:40:75
    Bid: 2023-10-05 10:18:40:75
    Ask: 2023-10-05 10:18:40:69
    Bid: 2023-10-05 10:18:40:69
    Last: 2023-10-05 10:18:40:69
    Ask: 2023-10-05 10:18:40:70
    Bid: 2023-10-05 10:18:40:70
    Last: 2023-10-05 10:18:40:70
    Last: 2023-10-05 10:18:40:70
    Ask: 2023-10-05 10:18:40:71​​
    Here is the code used to print these events:
    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if (e.MarketDataType == MarketDataType.Last)
    {
    Print("Last: " + e.Time.ToString("yyyy-MM-dd hh:mm:ss:ff"));
    }
    else if (e.MarketDataType == MarketDataType.Ask)
    {
    Print("Ask: " + e.Time.ToString("yyyy-MM-dd hh:mm:ss:ff"));
    }
    else if (e.MarketDataType == MarketDataType.Bid)
    {
    Print("Bid: " + e.Time.ToString("yyyy-MM-dd hh:mm:ss:ff"));
    }
    else
    {
    return;
    }
    }
    Thank you!

    #2
    Hello youraveragejoe,

    The time that comes with each event is the time that the exchange recorded for that event.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse! Thanks for the quick response.

      Got it, that makes sense. Is the delay in getting the data (getting the events out of order) expected or is it a problem with my computer? Where is the delay happening?

      Comment


        #4
        Hello youraveragejoe,

        The events that OnMarketData receives are pushed directly from the data provider and the platform displays the events in the sequence that was provided. I am not aware of any resource that says the events have to come in a specific order in regard to the timestamp that was recorded.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello!

          I've got the same issue with MarketDataEventArgs.Time.
          Sometimes the current OnMarketData event has a Time even up to 1-2 minutes(!) less than the time of the previous event.
          Does this mean that the order in which such events are received by NT is broken somewhere along the way?

          Comment


            #6
            Hello curious ,

            The market data event timestamps are recorded by the exchanged, your broker then provides the data with those timestamps. The timestamps on the data you get are based on the events that were observed in the market. You can see the following page to see if your broker uses native timestamps or local timestamps. https://ninjatrader.com/support/help...rical+provider

            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by TraderJA, Today, 12:06 AM
            0 responses
            4 views
            0 likes
            Last Post TraderJA  
            Started by SnailHorn, Yesterday, 10:49 PM
            0 responses
            7 views
            0 likes
            Last Post SnailHorn  
            Started by naanku, Yesterday, 07:25 PM
            0 responses
            8 views
            0 likes
            Last Post naanku
            by naanku
             
            Started by milfocs, Yesterday, 07:23 PM
            0 responses
            6 views
            0 likes
            Last Post milfocs
            by milfocs
             
            Started by PaulMohn, Yesterday, 06:59 PM
            0 responses
            8 views
            0 likes
            Last Post PaulMohn  
            Working...
            X