public Recordset Keltner(Navigator pNav, Recordset pOHLCV, int Periods, double Factor, IndicatorType MAType, string Alias) { // Same as STARC Recordset Results = new Recordset(); int recordCount = pOHLCV.GetField("Close").RecordCount; Field top = new Field(); top.Initialize(recordCount, Alias + " Top"); Field bottom = new Field(); bottom.Initialize(recordCount, Alias + " Bottom"); Oscillator os = new Oscillator(); Field tr = os.TrueRange(pNav, pOHLCV, "atr").GetField("atr"); MovingAverage ma = new MovingAverage(); Field atr = ma.SimpleMovingAverage(pNav, tr, Periods, "atr").GetField("atr"); Field median = ma.MovingAverageSwitch(pNav, pOHLCV.GetField("Close"), Periods, MAType, Alias + " Median").GetField(Alias + " Median"); for (int record = 1; record < recordCount + 1; record++) { double shift = Factor * atr.ValueEx(record); top.SetValue(record, median.Value(record) + shift); bottom.SetValue(record, median.Value(record) - shift); } Results.AddField(top); Results.AddField(median); Results.AddField(bottom); return(Results); }