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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    626 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 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
    562 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    567 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X