Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Stanfillirenfro, Today, 07:23 AM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by FitSpressoHonest, Today, 09:14 AM
          0 responses
          0 views
          0 likes
          Last Post FitSpressoHonest  
          Started by Davide999, 05-18-2023, 03:55 AM
          4 responses
          556 views
          1 like
          Last Post kcwasher  
          Started by rexsole, Today, 08:39 AM
          2 responses
          7 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          6 responses
          29 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X