Support Board
Date/Time: Mon, 25 Nov 2024 15:02:39 +0000
[Programming Help] - Study: Horizontal Lines At Increment (Round to Tick)
View Count: 274
[2024-02-24 02:09:32] |
User688525 - Posts: 257 |
Hello, Can assistance please be provided to add "Round to Tick" functionality to the "Horizontal Lines At Increment" study? I have added SCInputRef Input_RoundToTickSize = sc.Input[3]; and Input_RoundToTickSize.Name = "Round To Nearest Tick Size"; Input_RoundToTickSize.SetYesNo(0); to the "Horizontal Lines At Increment" code in "Studies7.cpp": #include "sierrachart.h" SCDLLName("Horizontal Lines At Increment v2") SCSFExport scsf_HorizontalLinesAtIncrementv2(SCStudyInterfaceRef sc) { const int NumberOfLines = SC_SUBGRAPHS_AVAILABLE - 1; SCInputRef Input_StartValue = sc.Input[0]; SCInputRef Input_LineIncrement = sc.Input[1]; SCInputRef Input_SetAllSubgraphsToBeSameAsFirst = sc.Input[2]; SCInputRef Input_RoundToTickSize = sc.Input[3]; if (sc.SetDefaults) { sc.GraphName = "Horizontal Lines At Increment v2"; sc.ValueFormat = VALUEFORMAT_INHERITED; sc.DisplayStudyInputValues = false; sc.ScaleRangeType = SCALE_SAMEASREGION; sc.GraphRegion = 0; for (int SubgraphIndex = 0; SubgraphIndex < NumberOfLines; SubgraphIndex++) { sc.Subgraph[SubgraphIndex].Name.Format("Line%d", SubgraphIndex + 1); sc.Subgraph[SubgraphIndex].DrawStyle = DRAWSTYLE_LINE; sc.Subgraph[SubgraphIndex].PrimaryColor = RGB(0,255,0); sc.Subgraph[SubgraphIndex].DrawZeros = false; sc.Subgraph[SubgraphIndex].DisplayNameValueInWindowsFlags = false; } Input_SetAllSubgraphsToBeSameAsFirst.Name = "Set All Subgraph Display Settings to Be Same as First"; Input_SetAllSubgraphsToBeSameAsFirst.SetYesNo(false); Input_StartValue.Name = "Start Value"; Input_StartValue.SetFloat(0); Input_LineIncrement.Name = "Line Increment"; Input_LineIncrement.SetFloat(1); Input_RoundToTickSize.Name = "Round To Nearest Tick Size"; Input_RoundToTickSize.SetYesNo(0); return; } for(int BarIndex = sc.UpdateStartIndex; BarIndex < sc.ArraySize; BarIndex++) { float CurrentLineValue = Input_StartValue.GetFloat(); for (int SubgraphIndex = 0; SubgraphIndex < NumberOfLines; SubgraphIndex++) { if (sc.Subgraph[SubgraphIndex].DrawStyle == DRAWSTYLE_IGNORE) continue; if (sc.IsFullRecalculation && BarIndex == 0 && Input_SetAllSubgraphsToBeSameAsFirst.GetYesNo() && SubgraphIndex > 0) { sc.Subgraph[SubgraphIndex].DrawStyle = sc.Subgraph[0].DrawStyle; sc.Subgraph[SubgraphIndex].PrimaryColor = sc.Subgraph[0].PrimaryColor; sc.Subgraph[SubgraphIndex].LineStyle = sc.Subgraph[0].LineStyle; sc.Subgraph[SubgraphIndex].LineWidth = sc.Subgraph[0].LineWidth; sc.Subgraph[SubgraphIndex].LineLabel = sc.Subgraph[0].LineLabel; } sc.Subgraph[SubgraphIndex][BarIndex] = CurrentLineValue; CurrentLineValue += Input_LineIncrement.GetFloat(); } } Thank you |
[2024-02-26 04:42:26] |
User688525 - Posts: 257 |
With the above, I would like round to the nearest tick size AFTER the levels have been calculated based on the increment, not beforehand, as this will result in each level increasing/decreasing based on the increment from a rounded level.
|
To post a message in this thread, you need to log in with your Sierra Chart account: