Support Board
Date/Time: Tue, 26 Nov 2024 21:24:57 +0000
[Programming Help] - Color of Subgraph getting reset incorrectly inconsistently.
View Count: 260
[2023-10-17 20:54:54] |
rajeshh - Posts: 8 |
Hello - I have the study below to illustrate the problem I am having. Would appreciate anyone trying it out and seeing why its doing so? /*
The following study is to illustrate the problem I am having - Basically I am showing an UP arrow below a bar n-1 when the next bar n goes above it, and a DOWN arrow above a bar when the next bar goes below its low. If the bar n also takes out the other side of the bar n-1, I want the arrows to be colored yellow. This is not working consistently for all the bars. Looking at my code, once yellow color has been set on the bar, I dont understand how its getting reset. */ SCSFExport scsf_TestLastDataColor(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_Down = sc.Subgraph[0]; SCSubgraphRef Subgraph_Up = sc.Subgraph[1]; if (sc.SetDefaults) { sc.GraphName = "Test Last DataColor"; sc.AutoLoop = true; sc.GraphRegion = 0; sc.ValueFormat= VALUEFORMAT_INHERITED; Subgraph_Down.Name = "Down"; Subgraph_Down.DrawStyle = DRAWSTYLE_ARROW_DOWN; Subgraph_Down.DrawZeros = false; Subgraph_Down.LineWidth = 1; Subgraph_Up.Name = "Up"; Subgraph_Up.DrawStyle = DRAWSTYLE_ARROW_UP; Subgraph_Up.DrawZeros = false; Subgraph_Up.LineWidth = 1; return; } int n = sc.Index; bool UpTriggered, DownTriggered; UpTriggered = sc.High[n] > sc.High[n-1]; //Bar n has gone above prior bar n-1 DownTriggered = sc.Low[n] < sc.Low[n-1]; //Bar n has gone below prior bar n-1 if (UpTriggered ) { //Only set it if it hasnt been set already if ( Subgraph_Up[n-1] ==0 ) { Subgraph_Up[n-1] = sc.Low[n-1] - sc.TickSize; Subgraph_Up.DataColor[n-1] = RGB(0,200,255); } } else Subgraph_Up[n-1] = 0; if (DownTriggered ) { //Only set it if it hasnt been set already if ( Subgraph_Down[n-1] ==0) { Subgraph_Down[n-1] = sc.High[n-1] + sc.TickSize; Subgraph_Down.DataColor[n-1] = COLOR_RED; } } else Subgraph_Down[n-1] = 0; //Bar n has gone above the prior bar and then below the prior bar //In this case, color the arrow Yellow. if (UpTriggered && sc.BaseData[SC_LAST][n] < sc.Low[n-1]) { Subgraph_Up.DataColor[n-1] = COLOR_YELLOW; } //Bar n has gone below the prior bar and then above the prior bar //In this case, color the arrow Yellow. if (DownTriggered && sc.BaseData[SC_LAST][n] > sc.High[n-1] ) { Subgraph_Down.DataColor[n-1] = COLOR_YELLOW; } } |
[2023-10-17 23:04:52] |
rajeshh - Posts: 8 |
So I did a little more troubleshooting and it doesn't seem the yellow color is getting reset, as much as it isn't getting set in the first place in some cases, when clearly the bar should have been set to yellow. Does this have to do with how often the study is getting called, and whether the check against SC_LAST price is fulfilling the check at that time?
|
To post a message in this thread, you need to log in with your Sierra Chart account: