Login Page - Create Account

Support Board


Date/Time: Wed, 30 Apr 2025 14:38:07 +0000



Post From: Market Depth: NumOrders is correct, but Quantity always 0

[2025-04-07 02:12:46]
Thanthou - Posts: 6
The following custom study is designed to gather ask price, quantity, and orders. However, quantity is always 0. Any help would be appreciated.


SCSFExport scsf_AskDepthDisplay(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.GraphName = "Ask Depth Display";
    sc.AutoLoop = 0;
    sc.GraphRegion = 2;
    sc.ValueFormat = 2;
    sc.UsesMarketDepthData = 1;
    
    return;
  }

  const int maxLevels = 10;
  SCString text;
  float last = sc.Close[sc.Index];

  for (int level = 0; level < maxLevels; ++level)
  {
    s_MarketDepthEntry entry;
    if (sc.GetAskMarketDepthEntryAtLevel(entry, level))
    {
      if (entry.Price > last && (entry.Price - last) / sc.TickSize <= 10)
      {
        text.AppendFormat("Ask %d: %.2f | Qty: %d | Orders: %d\n",
          level + 1, entry.Price, entry.Quantity, entry.NumOrders);
      }
    }
  }

  s_UseTool Tool;
  Tool.Clear();
  Tool.ChartNumber = sc.ChartNumber;
  Tool.DrawingType = DRAWING_TEXT;
  Tool.Region = sc.GraphRegion;
  Tool.BeginDateTime = sc.BaseDateTimeIn[sc.Index];
  Tool.BeginValue = 0;
  Tool.Text = text;
  Tool.Color = RGB(0,0,255);
  Tool.FontSize = 12;
  Tool.LineNumber = 999;
  Tool.AddMethod = UTAM_ADD_OR_ADJUST;
  Tool.UseRelativeVerticalValues = true;
  Tool.MultiLineLabel = true;

  sc.UseTool(Tool);
}

imagemarket_depth.PNG / V - Attached On 2025-04-07 02:11:37 UTC - Size: 200.19 KB - 25 views
Attachment Deleted.