Support Board
Date/Time: Sun, 24 Nov 2024 18:54:01 +0000
Post From: Implementation of Wilson RSI Channel in Sierra
[2013-11-08 18:11:25] |
vegasfoster - Posts: 444 |
Ok, I did this but the lines are going way off the chart and I can't see anything wrong with the conversion from what you posted. Maybe someone can take a look at this cuz I'm not seeing what's wrong with it. #include "sierrachart.h" SCDLLName("WilsonRelativePriceChannel") /*==========================================================================*/ SCSFExport scsf_WilsonRelativePriceChannel(SCStudyInterfaceRef sc) { SCSubgraphRef OB = sc.Subgraph[0]; SCSubgraphRef UNZ = sc.Subgraph[1]; SCSubgraphRef OS = sc.Subgraph[2]; SCSubgraphRef LNZ = sc.Subgraph[3]; SCSubgraphRef obinput = sc.Subgraph[4]; SCSubgraphRef unzinput = sc.Subgraph[5]; SCSubgraphRef osinput = sc.Subgraph[6]; SCSubgraphRef lnzinput = sc.Subgraph[7]; SCInputRef InputData = sc.Input[0]; SCInputRef Period = sc.Input[1]; SCInputRef Smoothing = sc.Input[2]; SCInputRef Overbought = sc.Input[3]; SCInputRef Oversold = sc.Input[4]; SCInputRef UpperNeutralZone = sc.Input[5]; SCInputRef LowerNeutralZone = sc.Input[6]; if (sc.SetDefaults) { sc.GraphName="Wilson Relative Price Channel"; sc.AutoLoop = 1; sc.GraphRegion = 0; sc.ValueFormat = 3; sc.FreeDLL = 1; // Subgraphs OB.Name = "OverBought"; OB.DrawStyle = DRAWSTYLE_LINE; OB.PrimaryColor = RGB(0,192,0); UNZ.Name = "Upper Neutral Zone"; UNZ.DrawStyle = DRAWSTYLE_LINE; UNZ.PrimaryColor = RGB(0,192,0); OS.Name = "OverSold"; OS.DrawStyle = DRAWSTYLE_LINE; OS.PrimaryColor = RGB(0,192,0); LNZ.Name = "Lower Neutral Zone"; LNZ.DrawStyle = DRAWSTYLE_LINE; LNZ.PrimaryColor = RGB(0,192,0); // Data Inputs InputData.Name = "Input Data"; InputData.SetInputDataIndex(SC_LAST); Period.Name = "Period"; Period.SetInt(34); Period.SetIntLimits(1, MAX_STUDY_LENGTH); Smoothing.Name = "Smoothing"; Smoothing.SetInt(1); Smoothing.SetIntLimits(1, MAX_STUDY_LENGTH); Overbought.Name = "Overbought"; Overbought.SetInt(70); Overbought.SetIntLimits(1, MAX_STUDY_LENGTH); Oversold.Name = "Overbought"; Oversold.SetInt(30); Oversold.SetIntLimits(1, MAX_STUDY_LENGTH); UpperNeutralZone.Name = "Period"; UpperNeutralZone.SetInt(55); UpperNeutralZone.SetIntLimits(1, MAX_STUDY_LENGTH); LowerNeutralZone.Name = "Period"; LowerNeutralZone.SetInt(45); LowerNeutralZone.SetIntLimits(1, MAX_STUDY_LENGTH); return; } if (sc.Index < Period.GetInt()) return; sc.RSI(sc.BaseDataIn[InputData.GetInputDataIndex()], sc.Subgraph[10], MOVAVGTYPE_WILDERS, Period.GetInt()); obinput[sc.Index] = sc.Subgraph[10][sc.Index] - Overbought.GetInt(); unzinput[sc.Index] = sc.Subgraph[10][sc.Index] - UpperNeutralZone.GetInt(); osinput[sc.Index] = sc.Subgraph[10][sc.Index] - Oversold.GetInt(); lnzinput[sc.Index] = sc.Subgraph[10][sc.Index] - LowerNeutralZone.GetInt(); sc.MovingAverage(obinput, sc.Subgraph[11], MOVAVGTYPE_EXPONENTIAL, Smoothing.GetInt()); sc.MovingAverage(unzinput, sc.Subgraph[12], MOVAVGTYPE_EXPONENTIAL, Smoothing.GetInt()); sc.MovingAverage(osinput, sc.Subgraph[13], MOVAVGTYPE_EXPONENTIAL, Smoothing.GetInt()); sc.MovingAverage(lnzinput, sc.Subgraph[14], MOVAVGTYPE_EXPONENTIAL, Smoothing.GetInt()); //plot O_B = close - (close*(OB/100)); //plot U_NZ = close - (close*(NZU/100)); //plot O_S = close - (close*(OS/100)); //plot L_NZ = close - (close*(NZL/100)); float InputD = sc.BaseDataIn[InputData.GetInputDataIndex()][sc.Index]; OB[sc.Index] = InputD - (InputD*(sc.Subgraph[11][sc.Index]/100)); UNZ[sc.Index] = InputD - (InputD*(sc.Subgraph[12][sc.Index]/100)); OS[sc.Index] = InputD - (InputD*(sc.Subgraph[13][sc.Index]/100)); LNZ[sc.Index] = InputD - (InputD*(sc.Subgraph[14][sc.Index]/100)); } |