public override double Calculate(IList <History> history) { double sumPlus = 0.0; PlusDX pdx = new PlusDX(); pdx.Calculate(history); PastValues.Add(0.0); // Get first for (int i = 1; i <= Period; i++) { PastValues.Add(pdx.PastValues[i]); sumPlus += pdx.PastValues[i]; } // First smoothdx values PastValues[Period] = (sumPlus / (double)Period); for (int h = Period + 1; h < history.Count; h++) { PastValues.Add(((PastValues[PastValues.Count - 1] * (Period - 1)) + (pdx.PastValues[h])) / (double)Period); } Value = PastValues[PastValues.Count - 1]; return(Value); }
public override double Calculate(IList <History> history) { double sum = 0.0; TrueRange tr = new TrueRange(); tr.Calculate(history); PastValues.Add(0.0); // Get first atr for (int i = 1; i <= Period; i++) { PastValues.Add(0.0); sum += tr.PastValues[i]; } // First ATR value PastValues[Period] = (sum / (double)Period); for (int h = Period + 1; h < history.Count; h++) { PastValues.Add(((PastValues[PastValues.Count - 1] * (Period - 1)) + (tr.PastValues[h])) / (double)Period); } Value = PastValues[PastValues.Count - 1]; return(Value); }
public override double Calculate(IList <History> history) { double hiDiff; double loDiff; //AverageTrueRange atr = new AverageTrueRange(14); //atr.Calculate(history); // First dxs are blank. Might have to set to NAN PastValues.Add(0.0); // Get [period] trs from beginning of history (250 records back) for (int i = 1; i < history.Count; i++) { hiDiff = (double)(history[i].HighPrice - history[i - 1].HighPrice); loDiff = (double)(history[i - 1].LowPrice - history[i].LowPrice); if ((hiDiff < 0.0 && loDiff < 0.0) || (hiDiff == loDiff)) { PastValues.Add(0.0); } else if (hiDiff > loDiff) { PastValues.Add(hiDiff); } else if (hiDiff < loDiff) { PastValues.Add(0.0); } } Value = PastValues[PastValues.Count - 1]; return(Value); }
public override double Calculate(IList <History> history) { double tr1; double tr2; double tr3; PastValues.Add(0.0); // Get [period] trs from beginning of history (250 records back) for (int i = 1; i < history.Count; i++) { tr1 = (double)(history[i].HighPrice - history[i].LowPrice); tr2 = (double)(Math.Abs(history[i].HighPrice - history[i - 1].ClosePrice)); tr3 = (double)(Math.Abs(history[i].LowPrice - history[i - 1].ClosePrice)); PastValues.Add(Math.Max(tr1, Math.Max(tr2, tr3))); } Value = PastValues[PastValues.Count - 1]; return(Value); }
public override double Calculate(IList <History> history) { PlusDMI pdmi = new PlusDMI(14); MinusDMI mdmi = new MinusDMI(14); pdmi.Calculate(history); mdmi.Calculate(history); for (int i = 0; i < Period; i++) { PastValues.Add(0.0); } for (int h = Period; h < history.Count; h++) { PastValues.Add((Math.Abs(pdmi.PastValues[h] - mdmi.PastValues[h]) / (pdmi.PastValues[h] + mdmi.PastValues[h])) * 100); } Value = PastValues[PastValues.Count - 1]; return(Value); }
public override double Calculate(IList <History> history) { MinusSmoothDX msdx = new MinusSmoothDX(14); msdx.Calculate(history); AverageTrueRange atr = new AverageTrueRange(14); atr.Calculate(history); for (int i = 0; i < Period; i++) { PastValues.Add(0.0); } for (int h = Period; h < history.Count; h++) { PastValues.Add((msdx.PastValues[h] / atr.PastValues[h]) * 100); } Value = PastValues[PastValues.Count - 1]; return(Value); }
public override double Calculate(IList <History> history) { DX dx = new DX(14); dx.Calculate(history); double sum = 0.0; // filler for (int i = 0; i < Period; i++) { PastValues.Add(0.0); } var dxObj = new DX(14); var dxVal = dxObj.Calculate(history); // Get first for (int h = Period; h < Period * 2; h++) { PastValues.Add(0.0); sum += 0.0; } PastValues[Period * 2 - 1] = sum / (double)Period; for (int h = Period * 2; h < history.Count; h++) { PastValues.Add(((PastValues[PastValues.Count - 1] * (Period - 1)) + (dx.PastValues[h])) / (double)Period); } Value = PastValues[PastValues.Count - 1]; return(Value); }