Announcement

Collapse
No announcement yet.

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.

    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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X