// Sierra Chart 2962+ source rebuild. Keep DLL names, exported study names, // subgraph indexes and input indexes unchanged for chartbook compatibility. // ACSIL source refreshed for Sierra Chart 2962+; rebuild against installed Sierra Chart headers. #include "sierrachart.h" SCDLLName("Custom Rotations And Price Points From High/Low - Tick Based With Custom Tick Size") SCSFExport scsf_RotationAndPricePointLevelsFromHL_TickBased_CustomTickSize(SCStudyInterfaceRef sc) { // ===== INPUTS ===== SCInputRef Input_StudyID = sc.Input[0]; SCInputRef Input_UseCustomTickSize = sc.Input[1]; SCInputRef Input_CustomTickSize = sc.Input[2]; SCInputRef Input_RotationSizeTicks = sc.Input[3]; SCInputRef Input_NumRotationLevels = sc.Input[4]; SCInputRef Input_ShowHighRotations = sc.Input[5]; SCInputRef Input_ShowLowRotations = sc.Input[6]; SCInputRef Input_UpsideRotationColor = sc.Input[7]; SCInputRef Input_DownsideRotationColor = sc.Input[8]; SCInputRef Input_ShowPricePoints = sc.Input[9]; SCInputRef Input_FirstPricePointOffsetTicks = sc.Input[10]; SCInputRef Input_PricePointStepSizeTicks = sc.Input[11]; SCInputRef Input_NumPricePointLevels = sc.Input[12]; SCInputRef Input_ShowHighPricePoints = sc.Input[13]; SCInputRef Input_ShowLowPricePoints = sc.Input[14]; SCInputRef Input_UpsidePricePointColor = sc.Input[15]; SCInputRef Input_DownsidePricePointColor = sc.Input[16]; if (sc.SetDefaults) { sc.GraphName = "Rotations And Price Points From High/Low - Tick Based With Custom Tick Size"; sc.StudyDescription = "Plots configurable rotation levels and price-point ladders from the High/Low for Time Period - Extended study using either the chart tick size or a user-defined tick size."; sc.AutoLoop = 1; sc.GraphRegion = 0; sc.DrawStudyUnderneathMainPriceGraph = 0; sc.ScaleRangeType = SCALE_SAMEASREGION; Input_StudyID.Name = "Study ID (High/Low Study)"; Input_StudyID.SetStudyID(1); Input_UseCustomTickSize.Name = "Use Custom Tick Size"; Input_UseCustomTickSize.SetYesNo(0); Input_CustomTickSize.Name = "Custom Tick Size"; Input_CustomTickSize.SetFloat(0.25f); Input_RotationSizeTicks.Name = "Rotation Size (Ticks)"; Input_RotationSizeTicks.SetInt(8); Input_RotationSizeTicks.SetIntLimits(0, 100000); Input_NumRotationLevels.Name = "Number of Rotation Levels"; Input_NumRotationLevels.SetInt(10); Input_NumRotationLevels.SetIntLimits(0, 15); Input_ShowHighRotations.Name = "Show High Rotations"; Input_ShowHighRotations.SetYesNo(1); Input_ShowLowRotations.Name = "Show Low Rotations"; Input_ShowLowRotations.SetYesNo(1); Input_UpsideRotationColor.Name = "Upside Rotation Color"; Input_UpsideRotationColor.SetColor(RGB(0, 255, 0)); Input_DownsideRotationColor.Name = "Downside Rotation Color"; Input_DownsideRotationColor.SetColor(RGB(255, 0, 0)); Input_ShowPricePoints.Name = "Show Price Points"; Input_ShowPricePoints.SetYesNo(1); Input_FirstPricePointOffsetTicks.Name = "First Price Point Offset (Ticks)"; Input_FirstPricePointOffsetTicks.SetInt(30); Input_FirstPricePointOffsetTicks.SetIntLimits(0, 100000); Input_PricePointStepSizeTicks.Name = "Price Point Step Size (Ticks)"; Input_PricePointStepSizeTicks.SetInt(60); Input_PricePointStepSizeTicks.SetIntLimits(0, 100000); Input_NumPricePointLevels.Name = "Number of Price Point Levels"; Input_NumPricePointLevels.SetInt(8); Input_NumPricePointLevels.SetIntLimits(0, 15); Input_ShowHighPricePoints.Name = "Show High Price Points"; Input_ShowHighPricePoints.SetYesNo(1); Input_ShowLowPricePoints.Name = "Show Low Price Points"; Input_ShowLowPricePoints.SetYesNo(1); Input_UpsidePricePointColor.Name = "Upside Price Point Color"; Input_UpsidePricePointColor.SetColor(RGB(0, 128, 255)); Input_DownsidePricePointColor.Name = "Downside Price Point Color"; Input_DownsidePricePointColor.SetColor(RGB(255, 128, 0)); for (int i = 0; i < 60; i++) { if (i < 15) sc.Subgraph[i].Name.Format("High Rotation %d", i + 1); else if (i < 30) sc.Subgraph[i].Name.Format("Low Rotation %d", i - 14); else if (i < 45) sc.Subgraph[i].Name.Format("High Price Point %d", i - 29); else sc.Subgraph[i].Name.Format("Low Price Point %d", i - 44); sc.Subgraph[i].DrawStyle = DRAWSTYLE_DASH; sc.Subgraph[i].LineWidth = 1; sc.Subgraph[i].DrawZeros = false; sc.Subgraph[i].PrimaryColor = RGB(0, 255, 0); sc.Subgraph[i].LineLabel = LL_DISPLAY_VALUE | LL_VALUE_ALIGN_VALUES_SCALE | LL_VALUE_ALIGN_CENTER; } return; } const int studyID = Input_StudyID.GetStudyID(); const int useCustomTickSize = Input_UseCustomTickSize.GetYesNo(); double tickSizeToUse = sc.TickSize; if (useCustomTickSize != 0) { const double customTickSize = Input_CustomTickSize.GetFloat(); if (customTickSize > 0.0) tickSizeToUse = customTickSize; } const int rotationSizeTicks = Input_RotationSizeTicks.GetInt(); const int numRotationLevels = Input_NumRotationLevels.GetInt(); const COLORREF upsideRotationColor = Input_UpsideRotationColor.GetColor(); const COLORREF downsideRotationColor = Input_DownsideRotationColor.GetColor(); const int showPricePoints = Input_ShowPricePoints.GetYesNo(); const int firstPricePointOffsetTicks = Input_FirstPricePointOffsetTicks.GetInt(); const int pricePointStepSizeTicks = Input_PricePointStepSizeTicks.GetInt(); const int numPricePointLevels = Input_NumPricePointLevels.GetInt(); const COLORREF upsidePricePointColor = Input_UpsidePricePointColor.GetColor(); const COLORREF downsidePricePointColor = Input_DownsidePricePointColor.GetColor(); const double rotationSize = static_cast(rotationSizeTicks) * tickSizeToUse; const double firstPricePointOffset = static_cast(firstPricePointOffsetTicks) * tickSizeToUse; const double pricePointStepSize = static_cast(pricePointStepSizeTicks) * tickSizeToUse; SCFloatArray HighArray; SCFloatArray LowArray; sc.GetStudyArrayUsingID(studyID, 0, HighArray); sc.GetStudyArrayUsingID(studyID, 1, LowArray); if (HighArray.GetArraySize() == 0 || LowArray.GetArraySize() == 0) return; if (sc.Index >= HighArray.GetArraySize() || sc.Index >= LowArray.GetArraySize()) return; const double high = HighArray[sc.Index]; const double low = LowArray[sc.Index]; if (high == 0.0 || low == 0.0) return; for (int i = 0; i < 60; i++) sc.Subgraph[i][sc.Index] = 0.0; if (Input_ShowHighRotations.GetYesNo()) { for (int i = 0; i < numRotationLevels && i < 15; i++) { const int sgIndex = i; sc.Subgraph[sgIndex][sc.Index] = high + (rotationSize * (i + 1)); sc.Subgraph[sgIndex].PrimaryColor = upsideRotationColor; sc.Subgraph[sgIndex].DrawStyle = DRAWSTYLE_DASH; sc.Subgraph[sgIndex].LineWidth = 1; } } if (Input_ShowLowRotations.GetYesNo()) { for (int i = 0; i < numRotationLevels && i < 15; i++) { const int sgIndex = 15 + i; sc.Subgraph[sgIndex][sc.Index] = low - (rotationSize * (i + 1)); sc.Subgraph[sgIndex].PrimaryColor = downsideRotationColor; sc.Subgraph[sgIndex].DrawStyle = DRAWSTYLE_DASH; sc.Subgraph[sgIndex].LineWidth = 1; } } if (showPricePoints && firstPricePointOffset > 0.0) { if (Input_ShowHighPricePoints.GetYesNo()) { for (int i = 0; i < numPricePointLevels && i < 15; i++) { const int sgIndex = 30 + i; const double level = high + firstPricePointOffset + (pricePointStepSize * i); sc.Subgraph[sgIndex][sc.Index] = level; sc.Subgraph[sgIndex].PrimaryColor = upsidePricePointColor; sc.Subgraph[sgIndex].DrawStyle = DRAWSTYLE_DASH; sc.Subgraph[sgIndex].LineWidth = 1; } } if (Input_ShowLowPricePoints.GetYesNo()) { for (int i = 0; i < numPricePointLevels && i < 15; i++) { const int sgIndex = 45 + i; const double level = low - firstPricePointOffset - (pricePointStepSize * i); sc.Subgraph[sgIndex][sc.Index] = level; sc.Subgraph[sgIndex].PrimaryColor = downsidePricePointColor; sc.Subgraph[sgIndex].DrawStyle = DRAWSTYLE_DASH; sc.Subgraph[sgIndex].LineWidth = 1; } } } }