Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error OnMarketData

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

    Error OnMarketData

    Hola,




    Por que cuando estoy leyendo el evento OnMarketData, el precio del Bid y del Ask, en tiempo real no coinciden a veces con la recarga del historico en TickReplay.




    Mi necesidad surge, porque en todo momento, necesito conocer cuando un contrato es casado, si este ha sido de forma agresiva, contra el Bid o contra el Ask.




    Adjunto un fragmento de código.

    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
    if (marketDataUpdate.MarketDataType != MarketDataType.Last)
    {
    return;
    }

    if (State != State.RealTime)
    {
    Print(string.format("{0}-{1}-{2}, marketDataUpdate.Bid, marketDataUpdate.Ask, marketDataUpdate.Bid);
    }
    else
    {
    Print(string.format("{0}-{1}-{2}, marketDataUpdate.Bid, marketDataUpdate.Ask, marketDataUpdate.Bid);
    }
    }


    This sometimes results in the following real-time results:
    ​5100 - 5100 - 5100

    and loading the history for example would be the following example:
    ​5100 - 5100- 5099,75


    Gracias por la respuesta.

    #2
    Hello FeelVolumeWave,

    Welcome to the NinjaTrader forums!

    Tenemos capacidad limitada para proporcionar soporte de plataforma en español; sin embargo, hemos encontrado que este sitio https://www.deepl.com/es/translator puede traducir el inglés al español con buena calidad. Por favor copie nuestra respuesta y luego navegue al sitio que le colocamos para pegar la respuesta en el cuadro hacia la izquierda.​

    TickReplay uses historical Last tick data. If the connected provider supports ask/bid stamped historical tick data, this will have the current ask or current bid at the time the last tick was saved.
    This means the ask/bid stamped historical tick data is not as complete as the real-time ask and bid updates as there can be ask/bid updates without a last tick being produced.

    This also means that OnMarketData will not be updating with MarketDataType.Ask or MarketDataType.Bid.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Could you tell me then what would be the most accurate formula to know if the tick of the onMarketData event is a buy or sell, because if I keep the Bid and Ask events received, sometimes the same thing happens, that at the time of the event, we would have that a tick has been able to marry at the same price that is the best Bid and the best Ask.

      Thanks​

      Comment


        #4
        Hello FeelVolumeWave,

        This is outlined in the help guide code sample linked in post # 2.

        Code:
        // TickReplay events only occur on the "Last" market data type
        if (marketDataUpdate.MarketDataType == MarketDataType.Last)
        {
        if (marketDataUpdate.Price >= marketDataUpdate.Ask)
        {
        Print(marketDataUpdate.Volume + " contracts traded at asking price " + marketDataUpdate.Ask);
        }
        
        else if (marketDataUpdate.Price <= marketDataUpdate.Bid)
        {
        Print(marketDataUpdate.Volume + " Contracts Traded at bidding price " + marketDataUpdate.Bid);
        }
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The problem is that when I do it this way, there are many last that in real time tells me that they have been aggressive purchases to market, but when I reload the chart with tick replay, it tells me that those last instead of purchases were sales again that tick instead of purchase tells me that it is sale. Logically changing the delta, number of contracts married in vos and ask. That is why I need to know for sure where and how to check in real time, if a last matched is a purchase or an aggressive sale and that when reloading the graph that has not changed and the same data.

          Thanks

          Comment


            #6
            Hello FeelVolumeWave,

            TickReplay will be using historical last tick data that can be ask/bid stamped. This may not be as accurate as the market updates during real-time as not all ask/bid market updates result in a last tick.

            You could choose to load historical ask and bid 1 tick dataseries with AddDataSeries() and process the information in OnBarUpdate().
            AddDataSeries(string instrumentName, BarsPeriodType periodType, int period, MarketDataType marketDataType)





            You could choose to record all of the live ask/bid market updates and write this to text file and then read this back from file.

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              The issue itself I have solved, but I was expecting a less expensive solution, as I understood that the OnMarketData event was for that purpose.

              Thank you very much for the answers and help

              Regards​

              Comment

              Latest Posts

              Collapse

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