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
+5 -2
View File
@@ -17,15 +17,17 @@ Abstract classes with all scaffolding required to build indicators.
</summary> */
public abstract class Single_TSeries_Indicator : TSeries
{
protected readonly int _p;
protected readonly int _period;
protected readonly bool _NaN;
protected readonly TSeries _data;
protected int _p;
// Chainable Constructor - add it at the end of primary constructor :base(source: source, period: period, useNaN: useNaN)
protected Single_TSeries_Indicator(TSeries source, int period, bool useNaN)
{
this._data = source;
this._p = period;
this._period = period;
this._p = _period;
this._NaN = useNaN;
this._data.Pub += this.Sub;
}
@@ -34,6 +36,7 @@ public abstract class Single_TSeries_Indicator : TSeries
public virtual void Add((System.DateTime t, double v) TValue, bool update, bool useNaN)
{
if (_period == 0) { _p = this.Length; }
var res = (TValue.t, this.Count < this._p - 1 && this._NaN ? double.NaN : TValue.v);
base.Add(res, update);
}