Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volume for each tick and candle

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

    Volume for each tick and candle

    Hi All!
    I want to count the number of Bid and Ask ticks and volume for each candle. But something is not correct.
    If I have a 30 tick candle, I think i would have AskTick + BidTick = 30, correct?
    What am I missing?
    Thanks in advance.
    Morris

    int AskTick = 0;
    int BidTick = 0;
    long AskVol = 0;
    long BidVol = 0;

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    // Print some data to the Output window
    if (e.MarketDataType == MarketDataType.Last) {
    // Totals for each candle
    Print(e.Time + " Last = " + e.Price + ", Vol = " + e.Volume);
    Print("Ask " + AskTick + " " + AskVol);
    AskTick=0;
    AskVol=0;
    Print("Bid " + BidTick + " " + BidVol);
    BidTick=0;
    BidVol=0;
    }
    else if (e.MarketDataType == MarketDataType.Ask) {
    AskTick++;
    AskVol+= e.Volume;
    Print(e.Time + " Ask = " + e.Price + ", Vol = " + e.Volume); // For each Ask tick
    }
    else if (e.MarketDataType == MarketDataType.Bid) {
    BidTick++;
    BidVol+= e.Volume;
    Print(e.Time + " Bid = " + e.Price + ", Vol = " + e.Volume); // For each Bid tick
    }
    }


    Example of my results:
    5/4/2022 12:37:31 AM Ask = 4174.5, Vol = 4
    5/4/2022 12:37:31 AM Bid = 4174.25, Vol = 10
    ========================= Is First Tick
    5/4/2022 12:37:31 AM 35
    ========================= Is First Tick
    Ask 157 1090
    Bid 157 988
    5/4/2022 12:37:31 AM Last = 4174.5, Vol = 2
    ========================= Is First Tick
    Ask 0 0
    Bid 0 0
    5/4/2022 12:37:31 AM Last = 4174.5, Vol = 1
    5/4/2022 12:37:31 AM Ask = 4174.75, Vol = 15
    5/4/2022 12:37:31 AM Ask = 4174.75, Vol = 14
    5/4/2022 12:37:31 AM Ask = 4174.75, Vol = 13


    #2
    I tiurned on the BuySellVolume indicator and set the bar size to 30 ticks. I am observing some nice extremes which will help me better understand what is going on with volume.
    The bar produced is Green (Buy) stacked on top of Red (Sell)

    What must change so that I can see the Buy and Sell bars displayed side by side instead of stacked?



    Click image for larger version

Name:	TikykTiky.png
Views:	843
Size:	529.1 KB
ID:	1199938

    Comment


      #3
      Hello morrnel,

      What you are seeing is correct, not every order is 1 volume. For a 30 tick chart you should see 30 ticks but the volume will vary a lot between bars.

      The buysellvolume indicator is generally how we suggest to make a script that accumulates volume.

      If you wanted to display the volume in a different way you would need to use OnRender or Plots to do that.

      Comment


        #4
        buy sell volume indicator
        See the missing bars to the left? What do I need to change so that all the bars are filled when I open ?
        Thanks.

        Click image for larger version

Name:	TikykTiky2.png
Views:	739
Size:	444.8 KB
ID:	1199955

        Comment


          #5
          Hello morrnel,

          That is correct, the BuySellVolume is a realtime indicator. You can turn on tick replay for it to estimate the historical results, for it to actually calculate as it would in realtime it would need to be run in realtime or forward through playback.

          Comment


            #6
            Kewl, thanks.

            Why didn't VOL need it?

            Comment


              #7
              Hello morrnel,

              The VOL indicator uses the Volume series which is based on historical data. The BuySellVolume uses OnMarketData which is not stored in historical data, by using TickReplay it can call OnMarketData historically.

              Comment

              Latest Posts

              Collapse

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