|
public class iATR : iBaseATR { int periods; double average;
iTrueRange TR; iSMA SMA; public iATR(int pPeriods) { periods = pPeriods; average = 0; TR = new iTrueRange(); SMA = new iSMA(pPeriods); }
public override void ReceiveTick(double pO, double pH, double pL, double pC) { TR.ReceiveTick(pO,pH,pL,pC);
if (TR.isPrimed()) { SMA.ReceiveTick(TR.Value()); } }
public override double Value() { double v=0; if (isPrimed()) { v = SMA.Value(); } return v; }
// returns true when indicator has seen enough values to compute a result // it will never return true if initialization parameters are incorrect // this will cause indicator to silently fail and not give results // on optimization runs where parameter combination is invalid. public override bool isPrimed() { bool v = false; if (SMA.isPrimed()) { v = true; } return v; } }
|