Support Board
Date/Time: Mon, 23 Jun 2025 20:20:18 +0000
Post From: ACSIL - Modify Swing High / Low? Ray instead of Line
[2022-02-14 08:33:18] |
User843553 - Posts: 1 |
Hello everyone, I would like to use the Swing High Low study, but would like to not end the horizontal lines at a price intersection. Basically use a ray instead of a line. I have tried modifying it over and over, but not had any success. Does anyone have any tips here? Thanks! This is the default code of the study: SCSFExport scsf_SwingHighAndLow(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_SwingHigh = sc.Subgraph[0]; SCSubgraphRef Subgraph_SwingLow = sc.Subgraph[1]; SCSubgraphRef Subgraph_LineProperties = sc.Subgraph[2]; SCInputRef Input_ArrowOffsetValue = sc.Input[0]; SCInputRef Input_Length = sc.Input[1]; SCInputRef Input_AllowEqualBars = sc.Input[2]; SCInputRef Input_ExtendSwings = sc.Input[3]; if (sc.SetDefaults) { sc.GraphName = "Swing High And Low"; sc.AutoLoop = true; sc.GraphRegion = 0; sc.ValueFormat= VALUEFORMAT_INHERITED; Subgraph_SwingHigh.Name = "Swing High"; Subgraph_SwingHigh.DrawStyle = DRAWSTYLE_ARROW_DOWN; Subgraph_SwingHigh.PrimaryColor = RGB(0,255,0); Subgraph_SwingHigh.DrawZeros = false; Subgraph_SwingHigh.PrimaryColor = RGB(255,0,0); Subgraph_SwingHigh.LineWidth = 3; Subgraph_SwingLow.Name = "Swing Low"; Subgraph_SwingLow.DrawStyle = DRAWSTYLE_ARROW_UP; Subgraph_SwingLow.PrimaryColor = RGB(255,0,255); Subgraph_SwingLow.DrawZeros = false; Subgraph_SwingLow.LineWidth = 3; Subgraph_SwingLow.PrimaryColor = RGB(0,255,0); Subgraph_LineProperties.Name = "Line Properties"; Subgraph_LineProperties.DrawStyle = DRAWSTYLE_SUBGRAPH_NAME_AND_VALUE_LABELS_ONLY; Subgraph_LineProperties.LineWidth = 1; Subgraph_LineProperties.PrimaryColor = RGB(255, 0, 0); Subgraph_LineProperties.SecondaryColor = RGB(0, 255, 0); Subgraph_LineProperties.SecondaryColorUsed = true; Subgraph_LineProperties.DrawZeros = false; Input_ArrowOffsetValue.Name = "Arrow Offset as Percentage"; Input_ArrowOffsetValue.SetFloat(3); Input_Length.Name = "Length"; Input_Length.SetInt(1); Input_Length.SetIntLimits(1,MAX_STUDY_LENGTH); Input_AllowEqualBars.Name = "Allow Equal High/Low Bars"; Input_AllowEqualBars.SetYesNo(false); Input_ExtendSwings.Name = "Extend Swings Until Future Intersection"; Input_ExtendSwings.SetYesNo(false); return; } int IndexToEvaluate = sc.Index - Input_Length.GetInt(); if(IndexToEvaluate - Input_Length.GetInt() < 0) { return; } sc.EarliestUpdateSubgraphDataArrayIndex = IndexToEvaluate; float ArrowOffset=(sc.High[IndexToEvaluate] - sc.Low[IndexToEvaluate] )*(Input_ArrowOffsetValue.GetFloat() * 0.01f); Subgraph_SwingHigh[IndexToEvaluate] = 0; Subgraph_SwingLow[IndexToEvaluate] = 0; // check for Swing High if (!Input_AllowEqualBars.GetYesNo()) { if (sc.IsSwingHigh(sc.High, IndexToEvaluate, Input_Length.GetInt())) Subgraph_SwingHigh[IndexToEvaluate] = sc.High[IndexToEvaluate] + ArrowOffset; } else if (IsSwingHighAllowEqual_S( sc, true , IndexToEvaluate, Input_Length.GetInt())) Subgraph_SwingHigh[IndexToEvaluate] = sc.High[IndexToEvaluate] + ArrowOffset; // check for Swing Low if (!Input_AllowEqualBars.GetYesNo()) { if (sc.IsSwingLow(sc.Low, IndexToEvaluate, Input_Length.GetInt())) Subgraph_SwingLow[IndexToEvaluate] = sc.Low[IndexToEvaluate] - ArrowOffset; } else if (IsSwingLowAllowEqual_S(sc, true , IndexToEvaluate, Input_Length.GetInt())) Subgraph_SwingLow[IndexToEvaluate] = sc.Low[IndexToEvaluate] - ArrowOffset; if (Input_ExtendSwings.GetYesNo()) { if (Subgraph_SwingHigh[IndexToEvaluate] != 0) { sc.AddLineUntilFutureIntersection (IndexToEvaluate , 1 // LineIDForBar , Subgraph_SwingHigh[IndexToEvaluate] , Subgraph_LineProperties.PrimaryColor , Subgraph_LineProperties.LineWidth , Subgraph_LineProperties.LineStyle , false , false , "" ); } else { sc.DeleteLineUntilFutureIntersection(IndexToEvaluate, 1); } } if (Input_ExtendSwings.GetYesNo()) { if (Subgraph_SwingLow[IndexToEvaluate] != 0) { sc.AddLineUntilFutureIntersection (IndexToEvaluate , 2 // LineIDForBar , Subgraph_SwingLow[IndexToEvaluate] , Subgraph_LineProperties.SecondaryColor , Subgraph_LineProperties.LineWidth , Subgraph_LineProperties.LineStyle , false , false , "" ); } else { sc.DeleteLineUntilFutureIntersection(IndexToEvaluate, 2); } } } Date Time Of Last Edit: 2022-02-14 09:41:50
|