Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Delayed Market Data

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

    Delayed Market Data

    I have an indicator where I have set this up as shown below and if I watch the ^VIX in another chart it updates several seconds faster than when the OnMarketData event catches the change in ^VIX. Do you know a way to catch the change in ^VIX sooner? I set a breakpoint in the code on the OnMarketData event to be sure that it wasn't related to displaying and it wasn't.

    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Minute, 1);
    AddDataSeries(BarsPeriodType.Tick, 1);
    AddDataSeries("^VIX", BarsPeriodType.Tick, 1);
    ...

    Later on in code:
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
    base.OnMarketData(marketDataUpdate);
    if (marketDataUpdate.Instrument.FullName == "^VIX")
    {
    IsVIXFalling = false;
    IsVIXRising = false;
    VIXLast = VIX;
    VIX = Close[0];
    if (VIX > VIXLast)
    {
    IsVIXRising = true;
    }
    else if (VIXLast > VIX)
    {
    IsVIXFalling = true;
    }
    }

    Thank you

    #2
    Hello jalley,

    Thank you for your post.

    I believe the discrepancy you're seeing is due to using Close[0] which is linked to OnBarUpdate instead of getting the price from the MarketDataType.Last price. If you adjust the code as below and look at the print, you'll see some discrepancies between the last price reported and Close[0] lagging slightly behind:

    Code:
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
    
    if (marketDataUpdate.Instrument.FullName == "^VIX")
    {
    if (marketDataUpdate.MarketDataType == MarketDataType.Last)
    {
    IsVIXFalling = false;
    IsVIXRising = false;
    VIXLast = VIX;
    VIX = marketDataUpdate.Price;
    
    if (VIX > VIXLast)
    {
    IsVIXRising = true;
    }
    else if (VIXLast > VIX)
    {
    IsVIXFalling = true;
    }
    
    Print(String.Format("LastPrice: {0} - Is Rising: {1} - Is Falling: {2} - Close[0]: {3}", VIX, IsVIXRising, IsVIXFalling, Close[0]));
    
    }
    }
    }
    If you're wanting to get that price as soon as possible, referring to the latest Last price update would be the way to go.

    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    68 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    151 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X