Support Board
Date/Time: Wed, 12 Mar 2025 21:32:02 +0000
[Programming Help] - Same values repeated on all bars (should not)
View Count: 599
[2022-05-30 17:33:52] |
BenjFlame - Posts: 335 |
Hello, here is a calculation of delta. I know it's build-in in sierra but I will need to code it. SCSubgraphRef SubGraph_NQ_Volume_Delta = sc.Subgraph[1]; if (sc.SetDefaults) { sc.MaintainAdditionalChartDataArrays = 1; sc.CalculationPrecedence = LOW_PREC_LEVEL; // Set the defaults sc.GraphName = "INSTRUMENTS FLOW"; sc.GraphRegion = 0; sc.ScaleRangeType = SCALE_SAMEASREGION; SubGraph_NQ_Volume_Delta.Name = "NQ volume delta"; SubGraph_NQ_Volume_Delta.DrawStyle = DRAWSTYLE_TEXT; SubGraph_NQ_Volume_Delta.PrimaryColor = RGB(255, 255, 255); SubGraph_NQ_Volume_Delta.LineWidth = 12; sc.AutoLoop = 1; return; } float NqDelta = sc.BaseData[SC_ASKVOL][sc.Index] - sc.BaseData[SC_BIDVOL][sc.Index]; SCString NqDeltaText; NqDeltaText.Format("%.0f", NqDelta); SubGraph_NQ_Volume_Delta.TextDrawStyleText = NqDeltaText; SubGraph_NQ_Volume_Delta[sc.Index] = sc.Close[sc.Index] - 1; } That code displays the delta from last bar (which is correct) but under ALL the previous bars also, instead of each bar's value under it. Where is the mistake? |
[2022-05-30 17:41:32] |
BenjFlame - Posts: 335 |
Answering my own question: I guess I need to store the calculation in an array instead of a float...
|
[2022-05-30 19:17:30] |
BenjFlame - Posts: 335 |
I was wrong, it won't work even with an array: // NQ SCSubgraphRef SubGraph_NQ_Volume_Delta_Data = sc.Subgraph[0]; SCSubgraphRef SubGraph_NQ_Volume_Delta_Text = sc.Subgraph[1]; if (sc.SetDefaults) { // Set the defaults sc.MaintainAdditionalChartDataArrays = 1; sc.CalculationPrecedence = LOW_PREC_LEVEL; sc.GraphName = "MULTI INSTRUMENTS FLOW"; sc.GraphRegion = 0; sc.ScaleRangeType = SCALE_SAMEASREGION; // Graphs SubGraph_NQ_Volume_Delta_Text.Name = "NQ delta text"; SubGraph_NQ_Volume_Delta_Text.DrawStyle = DRAWSTYLE_TEXT; SubGraph_NQ_Volume_Delta_Text.LineWidth = 12; SubGraph_NQ_Volume_Delta_Data.Name = "Text"; sc.AutoLoop = 1; return; } SubGraph_NQ_Volume_Delta_Data[sc.Index] = sc.BaseData[SC_ASKVOL][sc.Index] - sc.BaseData[SC_BIDVOL][sc.Index]; SCString NqDeltaText; NqDeltaText.Format("%.0f", SubGraph_NQ_Volume_Delta_Data[sc.Index]); SubGraph_NQ_Volume_Delta_Text.TextDrawStyleText = NqDeltaText; SubGraph_NQ_Volume_Delta_Text[sc.Index] = sc.Close[sc.Index] - 1; and still display same last value under ALL bars. Why? |
[2022-05-30 20:10:33] |
User431178 - Posts: 613 |
When you use DRAWSTYLE_TEXT this means the specified text is drawn at each bar/column in the chart at the value specified in the corresponding Subgraph Data element. The actual text is specifed with sc.Subgraph[].TextDrawStyleText. The font height is specified through sc.Subgraph[].LineWidth. If sc.Subgraph[].DrawZeros is 0, and the sc.Subgraph Data element for a bar/column in the chart is set to zero, no text will be drawn. ACSIL Interface Members - sc.Subgraph Array: sc.Subgraph[].DrawStyle Maybe look at custom value at Y? Date Time Of Last Edit: 2022-05-30 20:11:27
|
[2022-05-30 21:36:35] |
BenjFlame - Posts: 335 |
Yeah, that's how they are doing it, so I guess it's the way.
|
To post a message in this thread, you need to log in with your Sierra Chart account: