Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

e.Volume Doesn't Match e.MarketData.Last.Volume

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

    e.Volume Doesn't Match e.MarketData.Last.Volume

    NT,

    I have a question about e.Volume and e.MarketData.Last.Volume

    Here is my code.

    ------------------------------------------------------------------------------------------------------------------

    protected override void OnMarketData(MarketDataEventArgs e)

    {

    if (e.MarketDataType == MarketDataType.Last )

    {

    eVolume += e.Volume;

    LastVolume += e.MarketData.Last.Volume;

    Print("OnMarketData Last Volume CurrentBar = " + CurrentBar + " LastVolume Total = " + LastVolume + " eVolume Total = " + eVolume);

    }
    }

    ---------------------------------------------------------------------------------------------------------------------

    If you look at the attached file, you will see that these values don't match all the time.

    Why are they different??? I would think that they would be identical.

    Which is correct???

    I used a 39 Tick chart displaying TF to collect the data.

    Thanks,

    RJay
    Attached Files
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    #2
    RJay,

    You are running into a race condition and most likely will not be able to compare these two together. The race condition is that NS events are only triggered after the core "data structure" is updated. This means that when the event goes to NS, the actual internal data structure may already be ahead of it so you can't compare the two. You would need to stick with one or the other. e.Volume is the NS one and e.MarketData.Last.Volume points to the internal data.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      RJay,

      You are running into a race condition and most likely will not be able to compare these two together. The race condition is that NS events are only triggered after the core "data structure" is updated. This means that when the event goes to NS, the actual internal data structure may already be ahead of it so you can't compare the two. You would need to stick with one or the other. e.Volume is the NS one and e.MarketData.Last.Volume points to the internal data.
      Hi Josh,

      What does NS stand for???

      Its a shame these don't match up.

      Which would you use and why?

      Thanks,

      RJay
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        NS stands for NinjaScript.

        For checking volume I would just use the e.Volume one since it will be in line with other aspects of your NinjaScript.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          NS stands for NinjaScript.

          For checking volume I would just use the e.Volume one since it will be in line with other aspects of your NinjaScript.

          OK, Thanks

          RJay
          RJay
          NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

          Comment

          Latest Posts

          Collapse

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