Support Board
Date/Time: Sun, 08 Sep 2024 00:45:54 +0000
[Programming Help] - Delta on DOM
View Count: 324
[2024-06-09 13:25:27] |
R108limbs - Posts: 6 |
Hello, I would like to add a column for Delta for Market Orders on each price level on my DOM. Is there any way I can do this? I've searched the Trade DOM settings and do not see anything resemblant. Thanks.
Date Time Of Last Edit: 2024-06-09 13:36:29
|
[2024-06-09 22:08:47] |
John - SC Support - Posts: 34254 |
We are not sure what exactly you are looking for. Are you looking for something on the DOM (and if so what is it) or are you wanting the delta for actual trades, which would be found in our Numbers Bars study. Refer to the following: Numbers Bars For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-06-10 01:56:36] |
R108limbs - Posts: 6 |
Yes, I'd like the delta for the actual trades on each price level. If there isn't one on the DOM, is there a way I can copy it from the number bar settings and have it paste its value on a column? I don't mind coding it. I would want the delta to cumulate as well and only reset daily.
|
[2024-06-10 14:28:55] |
John - SC Support - Posts: 34254 |
There is not a built-in way to do what you are wanting. You could create a custom study that would calculate the delta you want and then display it in one of the "General Purpose" columns. Refer to the following: ACSIL Programming Concepts: Accessing Volume at Price Data Per Bar sc.GetDOMColumnLeftCoordinate() For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-06-22 16:26:01] |
R108limbs - Posts: 6 |
Hello, its been a while but I've managed to find some time to create a script for my requested function. The values are calculating correctly but I'm not sure why they're not getting printed into the actual DOM column. Do you think you could diagnose the problem? Thanks. #include "sierrachart.h" SCDLLName("DeltaInDOMColumnExample") struct CumulativeDeltaData { int cumulativeDelta; int lastTradeIndex; }; SCSFExport scsf_DeltaInDOMColumnExample(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Delta in DOM Column Example"; sc.MaintainVolumeAtPriceData = 1; sc.AutoLoop = 1; return; } static CumulativeDeltaData cdData; if (sc.IsFullRecalculation) { cdData.cumulativeDelta = 0; cdData.lastTradeIndex = 0; } // Calculate CD int newTradesIndex = sc.VolumeAtPriceForBars->GetNumberOfBars() - 1; for (int barIndex = cdData.lastTradeIndex; barIndex <= newTradesIndex; ++barIndex) { if (barIndex < 0 || barIndex >= sc.ArraySize) continue; int VAPSizeAtBarIndex = sc.VolumeAtPriceForBars->GetSizeAtBarIndex(barIndex); for (int VAPIndex = 0; VAPIndex < VAPSizeAtBarIndex; ++VAPIndex) { const s_VolumeAtPriceV2* p_VolumeAtPrice = NULL; if (!sc.VolumeAtPriceForBars->GetVAPElementAtIndex(barIndex, VAPIndex, &p_VolumeAtPrice)) break; if (p_VolumeAtPrice) { cdData.cumulativeDelta += (p_VolumeAtPrice->BidVolume - p_VolumeAtPrice->AskVolume); } } } cdData.lastTradeIndex = newTradesIndex; // Debug SCString debugText; debugText.Format("Cumulative Delta: %d", cdData.cumulativeDelta); sc.AddMessageToLog(debugText, 0); // CD in column SCString text; text.Format("%d", cdData.cumulativeDelta); s_UseTool tool; tool.Clear(); tool.ChartNumber = sc.ChartNumber; tool.DrawingType = DRAWING_TEXT; tool.AddAsUserDrawnDrawing = 1; tool.UseRelativeVerticalValues = 1; tool.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1]; // Use the last bar's datetime tool.Text = text; tool.Color = RGB(255, 0, 0); // Red color for visibility tool.FontSize = 12; tool.FontBold = true; tool.Region = 0; tool.TextAlignment = DT_CENTER | DT_VCENTER; // Center text tool.AddMethod = UTAM_ADD_OR_ADJUST; int leftCoordinate = sc.GetDOMColumnLeftCoordinate(n_ACSIL::DOM_COLUMN_GENERAL_PURPOSE_1); int rightCoordinate = sc.GetDOMColumnRightCoordinate(n_ACSIL::DOM_COLUMN_GENERAL_PURPOSE_1); int middleCoordinate = (leftCoordinate + rightCoordinate) / 2; tool.BeginValue = 0; tool.BeginDateTime = middleCoordinate; // Set the horizontal position sc.UseTool(tool); sc.AddMessageToLog("Text drawing tool was used to draw the delta.", 0); } |
[2024-06-22 16:37:48] |
User907968 - Posts: 815 |
The values are calculating correctly but I'm not sure why they're not getting printed into the actual DOM column. Do you think you could diagnose the problem?
Pretty sure you can't use drawing tools in those DOM columns. You would need to use different functionality - ACSIL Programming Concepts: Custom Free Form Drawing into Chart Window Using GDI (Graphics Device Interface) The comment in the link about not working with OpenGL out of date. If you check the file referenced in the link, you will find example of how to draw text etc. |
[2024-06-22 18:22:01] |
R108limbs - Posts: 6 |
I don't necessarily need to draw it into the column, I just want it in the column itself.
|
[2024-06-22 18:45:58] |
User907968 - Posts: 815 |
Drawing it is the only way to get it there.
|
To post a message in this thread, you need to log in with your Sierra Chart account: