better EMA

This commit is contained in:
Miha Kralj
2022-11-21 11:33:53 -08:00
parent f393ec336d
commit ae168ee345
9 changed files with 545 additions and 107 deletions
+7 -9
View File
@@ -5,7 +5,7 @@ using System;
ADL: Chaikin Accumulation/Distribution Line
ADL is a volume-based indicator that measures the cumulative Money Flow Volume:
1. Money Flow Multiplier = [(Close - Low) - (High - Close)] /(High - Low)
1. Money Flow Multiplier = [(Close - Low) - (High - Close)] /(High - Low)
2. Money Flow Volume = Money Flow Multiplier x Volume for the Period
3. ADL = Previous ADL + Current Period's Money Flow Volume
@@ -20,19 +20,17 @@ public class ADL_Series : Single_TBars_Indicator
public ADL_Series(TBars source, bool useNaN = false) : base(source, 0, useNaN)
{
this._lastadl = this._lastlastadl = 0;
if (_bars.Count > 0)
{ base.Add(_bars); }
_lastadl = _lastlastadl = 0;
if (_bars.Count > 0) { base.Add(_bars); }
}
public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update)
{
if (update)
{ this._lastadl = this._lastlastadl; }
if (update) { this._lastadl = this._lastlastadl; }
double _mfm = ((TBar.c - TBar.l) - (TBar.h - TBar.c)) / (TBar.h - TBar.l);
double _mfv = _mfm * TBar.v;
double _adl = this._lastadl + _mfv;
double _adl = 0;
double tmp = TBar.h - TBar.l;
if (tmp > 0.0 ) { _adl = _lastadl + ((2*TBar.c - TBar.l - TBar.h) / tmp * TBar.v); }
this._lastlastadl = this._lastadl;
this._lastadl = _adl;