Support Board
Date/Time: Wed, 30 Apr 2025 13:52:09 +0000
[Programming Help] - Market Depth: NumOrders is correct, but Quantity always 0
View Count: 91
[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); } |
![]() Attachment Deleted. |
[2025-04-07 09:22:08] |
User431178 - Posts: 656 |
Look at the definition of s_MarketDepthEntry, Quantity is not an integer, it's a double. text.AppendFormat("Ask %d: %.2f | Qty: %.0f | Orders: %d\n", level + 1, entry.Price, entry.Quantity, entry.NumOrders); or text.AppendFormat("Ask %d: %.2f | Qty: %d | Orders: %d\n", level + 1, entry.Price, static_cast<int>(entry.Quantity), entry.NumOrders); |
To post a message in this thread, you need to log in with your Sierra Chart account: