Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

first row of new event

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

    first row of new event

    Hi,

    I assume when the OnMarketData event happens NT runs through every event that is in the cache file.

    So if there are 10 trades you get 10 lines of data to run through.

    If I want to store the duration between events, how can find the first event and store the new tick time?



    Code:
           
     protected override void OnMarketData(MarketDataEventArgs e) 
            {
               // on first event do
               oldtime = now;
                now = DateTime.Now.Ticks;
    Thanks

    Tinkerz

    #2
    Hello tinkerz,

    Thanks for your note.

    The OnMarketData method will run upon receiving any market data such as an ask, bid, last, daily high/low/volume tick is received by NinjaTrader. Receiving a piece of data would be an event.

    Once received the OnMarketData will run with the "e" argument representing the piece of received data. It will run one time for each piece of data received.

    In your inquiry I'm not quite sure what you are asking. If you are asking if OnMarketData will run for the entirety of received data then no it will not do this. If you are asking if OnMarketData runs when an order is placed or receives an update, then no it will not do this either.

    Are you trying to find the amount of time between received pieces of data to get an idea of how quickly data is being received?

    If so, you are on the right track from the code provided. Using two variables to store the new time and old time would give you the time between ticks.

    You will want to create these variables as DateTime variables and use DateTime.Now without the succeeding .Tick.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    561 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    325 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X