Support Board
Date/Time: Wed, 27 Nov 2024 21:44:59 +0000
[Programming Help] - DRAWING_HORIZONTAL_RAY; Extend Until Future Intersection???
View Count: 419
[2023-06-26 00:31:59] |
User429065 - Posts: 118 |
Is there a similar function that adds a "Horizontal Ray Until Future Intersection" to the close of a study (not a bar) that's in a region other than price? I've tried the drawing function below with "ExtendUntilFutureInterection" but am unsuccessful. Thank you for any suggestions! tool.DrawingType = DRAWING_HORIZONTAL_RAY; SEE THE REST OF MY CODE BELOW: #include "sierrachart.h" SCDLLName("TrendeX_Naked_Closes") SCSFExport scsf_TrendeX_Naked_Closes(SCStudyInterfaceRef sc) { SCInputRef Input_StudySubgraph = sc.Input[0]; if (sc.SetDefaults) { // Set the configuration and defaults. sc.GraphName = "TrendeX Naked Closes"; sc.StudyDescription = "Plots a horizontal ray line at swing high and swing low pivots."; Input_StudySubgraph.Name = "Input Study and Subgraph"; Input_StudySubgraph.SetStudySubgraphValues(1, 0); // Defaults to study 1, subgraph 0 sc.AutoLoop = 1; sc.GraphRegion = 1; sc.ValueFormat = VALUEFORMAT_INHERITED; return; } SCFloatArray StudySubgraphArray; sc.GetStudyArrayUsingID(Input_StudySubgraph.GetStudyID(), Input_StudySubgraph.GetSubgraphIndex(), StudySubgraphArray); for (int Index = sc.UpdateStartIndex; Index < sc.ArraySize; ++Index) { if(Index < 2) continue; // Skip the first two bars // High pivot (3-bar reversal to the upside) if (StudySubgraphArray[Index - 1] > StudySubgraphArray[Index - 2] && StudySubgraphArray[Index - 1] > StudySubgraphArray[Index]) { s_UseTool tool; tool.Clear(); tool.ChartNumber = sc.ChartNumber; tool.DrawingType = DRAWING_HORIZONTAL_RAY; tool.BeginIndex = Index - 1; tool.BeginValue = StudySubgraphArray[Index - 1]; tool.Region = sc.GraphRegion; tool.Color = RGB(0, 255, 0); // Green tool.LineWidth = 2; tool.AddMethod = UTAM_ADD_ALWAYS; tool.ExtendUntilFutureIntersection = 1; sc.UseTool(tool); } // Low pivot (3-bar reversal to the downside) if (StudySubgraphArray[Index - 1] < StudySubgraphArray[Index - 2] && StudySubgraphArray[Index - 1] < StudySubgraphArray[Index]) { s_UseTool tool; tool.Clear(); tool.ChartNumber = sc.ChartNumber; tool.DrawingType = DRAWING_HORIZONTAL_RAY; tool.BeginIndex = Index - 1; tool.BeginValue = StudySubgraphArray[Index - 1]; tool.Region = sc.GraphRegion; tool.Color = RGB(255, 0, 0); // Red tool.LineWidth = 2; tool.AddMethod = UTAM_ADD_ALWAYS; tool.ExtendUntilFutureIntersection = 1; sc.UseTool(tool); } } } |
[2023-06-28 16:57:15] |
ForgivingComputers.com - Posts: 960 |
The Horizontal Ray drawing type by definition extends to the end of the chart. If you want a line that ends when intersected, start with DRAWING_HORIZONTAL_RAY, then when your study detects an intersection change the DrawingType to DRAWING_HORIZONTAL_LINE_NON_EXTENDED and set the end index to the bar where the intersection occurs.
Date Time Of Last Edit: 2023-06-28 16:59:02
|
[2023-06-28 20:31:01] |
User429065 - Posts: 118 |
Hey thanks, Brad for the tip!!! As you can see, I've added it to my code below but for some reason, this thing won't compile. Am I missing something here? The remote build did not succeed. Result: TrendeX_Naked_Closes.cpp: In function 'void scsf_TrendeX_Naked_Closes(SCStudyInterfaceRef)': TrendeX_Naked_Closes.cpp:67:84: error: too many arguments to function 67 | if (sc.ChartDrawingExists(sc.ChartNumber, DRAWING_HORIZONTAL_RAY, Index - 1)) | ^ -- End of Build -- 15:26:52 #include "sierrachart.h" SCDLLName("TrendeX_Naked_Closes") SCSFExport scsf_TrendeX_Naked_Closes(SCStudyInterfaceRef sc) { SCInputRef Input_StudySubgraph = sc.Input[0]; if (sc.SetDefaults) { // Set the configuration and defaults. sc.GraphName = "TrendeX Naked Closes"; sc.StudyDescription = "Plots a horizontal ray line at swing high and swing low pivots."; Input_StudySubgraph.Name = "Input Study and Subgraph"; Input_StudySubgraph.SetStudySubgraphValues(1, 0); // Defaults to study 1, subgraph 0 sc.AutoLoop = 1; sc.GraphRegion = 1; sc.ValueFormat = VALUEFORMAT_INHERITED; return; } SCFloatArray StudySubgraphArray; sc.GetStudyArrayUsingID(Input_StudySubgraph.GetStudyID(), Input_StudySubgraph.GetSubgraphIndex(), StudySubgraphArray); for (int Index = sc.UpdateStartIndex; Index < sc.ArraySize; ++Index) { if (Index < 2) continue; // Skip the first two bars // High pivot (3-bar reversal to the upside) if (StudySubgraphArray[Index - 1] > StudySubgraphArray[Index - 2] && StudySubgraphArray[Index - 1] > StudySubgraphArray[Index]) { s_UseTool tool; tool.Clear(); tool.ChartNumber = sc.ChartNumber; tool.DrawingType = DRAWING_HORIZONTAL_RAY; tool.BeginIndex = Index - 1; tool.BeginValue = StudySubgraphArray[Index - 1]; tool.Region = sc.GraphRegion; tool.Color = RGB(0, 255, 0); // Green tool.LineWidth = 2; tool.AddMethod = UTAM_ADD_ALWAYS; sc.UseTool(tool); } // Low pivot (3-bar reversal to the downside) if (StudySubgraphArray[Index - 1] < StudySubgraphArray[Index - 2] && StudySubgraphArray[Index - 1] < StudySubgraphArray[Index]) { s_UseTool tool; tool.Clear(); tool.ChartNumber = sc.ChartNumber; tool.DrawingType = DRAWING_HORIZONTAL_RAY; tool.BeginIndex = Index - 1; tool.BeginValue = StudySubgraphArray[Index - 1]; tool.Region = sc.GraphRegion; tool.Color = RGB(255, 0, 0); // Red tool.LineWidth = 2; tool.AddMethod = UTAM_ADD_ALWAYS; sc.UseTool(tool); } if (sc.ChartDrawingExists(sc.ChartNumber, DRAWING_HORIZONTAL_RAY, Index - 1)) { s_UseTool tool; tool.Clear(); tool.ChartNumber = sc.ChartNumber; tool.DrawingType = DRAWING_HORIZONTAL_LINE_NON_EXTENDED; tool.BeginIndex = Index - 1; tool.BeginValue = StudySubgraphArray[Index - 1]; tool.Color = RGB(0, 0, 255); // Blue tool.LineWidth = 2; tool.AddMethod = UTAM_ADD_OR_ADJUST; sc.UseTool(tool); } } } Date Time Of Last Edit: 2023-06-29 19:09:10
|
[2023-07-01 22:05:00] |
ForgivingComputers.com - Posts: 960 |
The error says you are using too many parameters in your function call. However, I think you will want to use sc.UserDrawnChartDrawingExists.
|
To post a message in this thread, you need to log in with your Sierra Chart account: