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

Difference between MarketDataType.Last Volume and VOL

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

    Difference between MarketDataType.Last Volume and VOL

    Hello,

    I try to write a very simple indicator based on MarketDataType.Last event but I have noticed that a cumulative volume on specific bar based on last traded price is different than VOL value. Let's take a look on example:

    Here is a simple code:

    if(e.MarketDataType == MarketDataType.Last)
    {
    sumvol += e.Volume;
    Print("CurrentBar =" + (CurrentBar+1).ToString() + " " + "SumVol = " + sumvol.ToString());
    }
    }

    protected override void OnBarUpdate()
    {
    if(IsFirstTickOfBar)
    {
    sumvol = 0;
    }
    }

    On 5 minutes chart it looks following:

    CurrentBar =4085 SumVol = 533
    CurrentBar =4085 SumVol = 534
    CurrentBar =4085 SumVol = 535
    CurrentBar =4086 SumVol = 1
    CurrentBar =4086 SumVol = 2
    CurrentBar =4086 SumVol = 3
    CurrentBar =4086 SumVol = 5

    There is a difference between the VOL which is 569 and the real time cumulative volume which is 535. When the new bar is created suddenly I observe missing volume. Please take a look on the screen.

    Furthermore, when bar is closed and I update/refresh a chart the value calculated from historical data is correct.

    CurrentBar =4085 SumVol = 563
    CurrentBar =4085 SumVol = 564
    CurrentBar =4085 SumVol = 565
    CurrentBar =4085 SumVol = 566
    CurrentBar =4085 SumVol = 567
    CurrentBar =4085 SumVol = 568
    CurrentBar =4085 SumVol = 569
    CurrentBar =4086 SumVol = 1
    CurrentBar =4086 SumVol = 2
    CurrentBar =4086 SumVol = 3
    CurrentBar =4086 SumVol = 5
    CurrentBar =4086 SumVol = 6
    CurrentBar =4086 SumVol = 7
    CurrentBar =4086 SumVol = 8
    CurrentBar =4086 SumVol = 9

    Could someone explain me why it happens?

    #2
    Hello kanarkia,

    Thank you for the note.

    You are resetting your sumvol variable on the first tick of the bar, and there is the volume for that tick, that is likely the cause of the difference. The buysellpressure or buysellvolume indicator would be a good place to look on how to collect bid/ask volumes.

    Please let me know if I can assist further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Thank you for your comment. I noticed that the difference appears when the bar is created, not on the beginning.Please take a look on next screen. Anyway, I will take a look on buysellpressure or buysellvolume indicator.

      Cheers

      Adam

      Comment


        #4
        Hello again,

        I have made some adjustments based on indicators provided by you and it works fine.

        Thanks for your help.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rocketman7, Today, 01:00 AM
        0 responses
        1 view
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        27 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 04-23-2024, 09:53 PM
        2 responses
        74 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        193 views
        0 likes
        Last Post Hasadafa  
        Working...
        X