Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 10:11:07 +0000



[Programming Help] - How to get traded volume on ask and bid price

View Count: 1192

[2016-10-14 14:31:51]
Alex1976 - Posts: 1
Hello all,
I spent lots of hours finding solution how to get traded volumes on ask and bid prices - same like T&S displays.
I use 1second chart and I want to display some mark if ask volume witin this bar exceeds some value, the same for bid.
I found some example o using timeandsales in studies.cpp. So I tried to use it.

SCTimeAndSalesArray TimeSales;
  sc.GetTimeAndSales(TimeSales);
  if (TimeSales.Size() == 0)
    return; // No Time and Sales data available for the symbol

  double ASKVOL = 0;
  double BIDVOL = 0;

  
  for (int TSIndex = TimeSales.Size() - 1; TSIndex >= 0; --TSIndex)
  {
      if (TimeSales[TSIndex].Type == SC_TS_BIDASKVALUES) continue;

      if (TimeSales[TSIndex].Type == SC_TS_BID)
      {
        MarkSize = 0;

        CurrentPrice = TimeSales[TSIndex].Price * sc.RealTimePriceMultiplier;
        BIDVOL = TimeSales[TSIndex].Volume * sc.MultiplierFromVolumeValueFormat();
. . .
{do something with BIDVOL}
. . .
}
      if (TimeSales[TSIndex].Type == SC_TS_ASK)
      {
        MarkSize = 0;

        CurrentPrice = TimeSales[TSIndex].Price * sc.RealTimePriceMultiplier;
        ASKVOL = TimeSales[TSIndex].Volume * sc.MultiplierFromVolumeValueFormat();
. . .
{do something with ASKVOL}
. . .
}

}


in section {do something with ASKVOL/BIDVOL}
I try to draw some text mark, MarkSize depends on BIDVOL and ASKVOL volume range (I have 3 ranges, 3 MarkSizes) MarkCounter variable is persistent and set in sc.SetDefaults to 0:

Tool.Clear();

          Tool.ChartNumber = sc.ChartNumber;
          Tool.DrawingType = DRAWING_TEXT;
          Tool.LineNumber = MarkCounter;
          Tool.BeginIndex = sc.Index;
          Tool.BeginValue = CurrentPrice;

          Tool.Color = MarkColor;
          Tool.FontFace = "Wingdings";
          Tool.FontSize = MarkSize;
          Tool.FontBold = FALSE;
          
          Tool.Text="l";

          Tool.TextAlignment = DT_CENTER | DT_VCENTER;
          Tool.AddMethod = UTAM_ADD_OR_ADJUST;

          sc.UseTool(Tool);
          
          MarkCounter++;


The problem is that it doesnt draw mark on every incoming data to T&S. Sometimes it does, sometimes it doesnt. WHY ???
Example: I set T&S to filter trades >=3, I set my range the same >=3. I watch T&S and see trade 4 volume on ask price, but my study doesnt draw any mark:( Then I watch 3 trades with volume>3 and my studie draws just 1 mark.
I have no clue where problem is :( Would you be so kind and help my somehow ?
Thank you very much for your assistance.
Best regards,
Alex

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account