public CMCSuperTrend(Bars bars, double ATRMultiple, int ATRPeriod, string description) : base(bars, description) { base.FirstValidValue = ATRPeriod * 3; int state = 1; for (int bar = FirstValidValue; bar < bars.Count; bar++) { double Value = 0; if (state == 1) { if (bars.Close[bar] < base[bar - 1]) { state = -1; Value = bars.High[bar] + ATRMultiple * ATR.Series(bars, ATRPeriod)[bar]; } else Value = Math.Max(this[bar - 1], bars.Low[bar] - ATRMultiple * ATR.Series(bars, ATRPeriod)[bar]); } else { if (bars.Close[bar] > base[bar - 1]) { state = 1; Value = bars.Low[bar] - ATRMultiple * ATR.Series(bars, ATRPeriod)[bar]; } else Value = Math.Min(this[bar - 1], bars.High[bar] + ATRMultiple * ATR.Series(bars, ATRPeriod)[bar]); } base[bar] = Value; } }
public AverageDistance(Bars bars, int period, string description) : base(bars, description) { base.FirstValidValue = period * 3; DataSeries sma = Community.Indicators.FastSMA.Series(bars.Close, period); ATR atr = ATR.Series(bars, period); for (int bar = FirstValidValue; bar < bars.Count; bar++) { base[bar] = (bars.Close[bar] - sma[bar]) / atr[bar]; } }
public MTSuperTrendSeries(Bars bars, int CCIPeriod, double ATRMultiple, int ATRPeriod, string description) : base(bars, description) { base.FirstValidValue = Math.Max(CCIPeriod, ATRPeriod * 3); for (int bar = FirstValidValue; bar < bars.Count; bar++) { double Value = 0; if (CCI.Series(bars, CCIPeriod)[bar] >= 0) { Value = Math.Max(base[bar - 1], bars.Low[bar] - ATRMultiple * ATR.Series(bars, ATRPeriod)[bar]); } else { Value = Math.Min(base[bar - 1], bars.High[bar] + ATRMultiple * ATR.Series(bars, ATRPeriod)[bar]); } base[bar] = Value; } }
public KaseCD(Bars bars, int fastPeriod, int slowPeriod, string description) : base(bars, description) { base.FirstValidValue = Math.Max(fastPeriod, slowPeriod); DataSeries RWH = new DataSeries(bars, "RWH"); DataSeries RWL = new DataSeries(bars, "RWL"); for (int bar = FirstValidValue; bar < bars.Count; bar++) { RWH[bar] = (((bars.High[bar] - bars.Low[bar - slowPeriod])) / ((ATR.Series(bars, slowPeriod)[bar] * Math.Sqrt(slowPeriod)))); RWL[bar] = (((bars.High[bar - slowPeriod] - bars.Low[bar])) / ((ATR.Series(bars, slowPeriod)[bar] * Math.Sqrt(slowPeriod)))); } DataSeries Pk = Community.Indicators.FastSMA.Series(WMA.Series((RWH - RWL), fastPeriod), fastPeriod); DataSeries KCD = Pk - Community.Indicators.FastSMA.Series(Pk, slowPeriod); for (int bar = FirstValidValue; bar < bars.Count; bar++) { base[bar] = KCD[bar]; } }
public HasslerTSI(Bars bars, DataSeries ds, int period1, int period2, string description) : base(ds, description) { base.FirstValidValue = Math.Max(period2, period1); if (FirstValidValue > ds.Count || FirstValidValue < 0) { FirstValidValue = ds.Count; } if (ds.Count < period1 || ds.Count < period2) { return; } ATR atr = ATR.Series(bars, period1); DataSeries Ratio = DataSeries.Abs(ds - (ds >> period1)) / atr; DataSeries HasslerTSI = Community.Indicators.FastSMA.Series(Community.Indicators.FastSMA.Series(Ratio, period1), period2); for (int i = FirstValidValue; i < ds.Count; i++) { base[i] = HasslerTSI[i]; } }
public ATRBandLower(Bars bars, DataSeries ds, int atrPeriod, double atrMult, string description) : base(bars, description) { base.FirstValidValue = Math.Max(ds.FirstValidValue, atrPeriod * 3); if (FirstValidValue > ds.Count || FirstValidValue < 0) { FirstValidValue = ds.Count; } if (ds.Count < atrPeriod) { return; } var rangePartitioner = Partitioner.Create(FirstValidValue, ds.Count); Parallel.ForEach(rangePartitioner, (range, loopState) => { for (int bar = range.Item1; bar < range.Item2; bar++) { base[bar] = ds[bar] - atrMult * ATR.Series(bars, atrPeriod)[bar]; } }); }
public KeltnerATR_Lower(Bars bars, int smaPeriod, int atrPeriod, double atrMult, string description) : base(bars, description) { base.FirstValidValue = Math.Max(smaPeriod, atrPeriod * 3); if (FirstValidValue > bars.Count || FirstValidValue < 0) { FirstValidValue = bars.Count; } if (bars.Count < Math.Max(smaPeriod, atrPeriod)) { return; } for (int bar = FirstValidValue; bar < bars.Count; bar++) { base[bar] = Community.Indicators.FastSMA.Series(WealthLab.Indicators.AveragePriceC.Series(bars), smaPeriod)[bar] - atrMult * ATR.Series(bars, atrPeriod)[bar]; } }