Support Board
Date/Time: Tue, 26 Nov 2024 15:18:12 +0000
Post From: Possible to change color of a Moving average based on condition?
[2023-11-24 02:37:04] |
Flipper_2 - Posts: 57 |
like this : ) SCSFExport scsf_Line_Color_Threshold(SCStudyInterfaceRef sc) { SCSubgraphRef ADX_Subgraph = sc.Subgraph[0]; SCSubgraphRef SMA_Subgraph = sc.Subgraph[1]; SCInputRef BarColor10 = sc.Input[0]; SCInputRef BarColor15 = sc.Input[1]; SCInputRef BarColor25 = sc.Input[2]; SCInputRef BarColor33 = sc.Input[3]; SCInputRef BarColor66 = sc.Input[4]; SCInputRef BarColor75 = sc.Input[6]; SCInputRef BarColor85 = sc.Input[6]; SCInputRef BarColor90 = sc.Input[7]; SCInputRef Input_DXLength = sc.Input[8]; SCInputRef Input_DXMovAngLength = sc.Input[9]; if (sc.SetDefaults) { sc.AutoLoop = 1; sc.GraphName = "Color Line Based on ADX"; sc.GraphRegion = 0; // Graphs ADX_Subgraph.Name = "ADX "; ADX_Subgraph.DrawStyle = DRAWSTYLE_IGNORE; ADX_Subgraph.DrawZeros = true; SMA_Subgraph.Name = "SMA "; SMA_Subgraph.DrawStyle = DRAWSTYLE_LINE; SMA_Subgraph.DrawZeros = true; // Inputs BarColor10.Name = "10% Bar Range Color"; BarColor10.SetColor(RGB(128, 0, 0)); BarColor15.Name = "15% Bar Range Color"; BarColor15.SetColor(RGB(255, 0, 0)); BarColor25.Name = "25% Bar Range Color"; BarColor25.SetColor(RGB(240, 128, 128)); BarColor33.Name = "33% Bar Range Color"; BarColor33.SetColor(RGB(255, 233, 108)); BarColor66.Name = "66% Bar Range Color"; BarColor66.SetColor(RGB(154, 205, 50)); BarColor75.Name = "75% Bar Range Color"; BarColor75.SetColor(RGB(173, 255, 47)); BarColor85.Name = "85% Bar Range Color"; BarColor85.SetColor(RGB(50, 205, 50)); BarColor90.Name = "90% Bar Range Color"; BarColor90.SetColor(RGB(0, 100, 0)); Input_DXLength.Name = "DX Length"; Input_DXLength.SetInt(14); Input_DXLength.SetIntLimits(1, INT_MAX); Input_DXMovAngLength.Name = "DX Mov Avg Length"; Input_DXMovAngLength.SetInt(14); Input_DXMovAngLength.SetIntLimits(1, INT_MAX); return; } sc.ADX(sc.BaseData, ADX_Subgraph, Input_DXLength.GetInt(), Input_DXMovAngLength.GetInt()); float adx = ADX_Subgraph[sc.Index]; sc.SimpleMovAvg(sc.Close, SMA_Subgraph, Input_DXLength.GetInt()); if (adx < 10) { SMA_Subgraph.DataColor[sc.Index] = BarColor10.GetColor(); } else if (adx < 15) { SMA_Subgraph.DataColor[sc.Index] = BarColor15.GetColor(); } else if (adx < 25) { SMA_Subgraph.DataColor[sc.Index] = BarColor25.GetColor();; } else if (adx < 33) { SMA_Subgraph.DataColor[sc.Index] = BarColor33.GetColor(); } else if (adx < 66) { SMA_Subgraph.DataColor[sc.Index] = BarColor66.GetColor(); } else if (adx < 75) { SMA_Subgraph.DataColor[sc.Index] = BarColor75.GetColor(); } else if (adx < 85) { SMA_Subgraph.DataColor[sc.Index] = BarColor85.GetColor(); } else { SMA_Subgraph.DataColor[sc.Index] = BarColor90.GetColor(); } } |