This commit is contained in:
Miha Kralj
2023-01-05 16:40:08 -08:00
parent bfcbf8d686
commit 7a0279b3d5
10 changed files with 273 additions and 183 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ FMA: Fibonacci Moving Average
Sources:
https://kaabar-sofien.medium.com/the-fibonacci-moving-average-the-full-guide-60e718117595
https://www.tradingview.com/script/6pxgp2vh-Fibonacci-Moving-Average-FMA/
https://usethinkscript.com/threads/fibonacci-moving-average.8099/
</summary> */
+7 -8
View File
@@ -39,17 +39,17 @@ public class KAMA_Series : Single_TSeries_Indicator
{
if (update){
_buffer[_buffer.Count - 1] = TValue.v;
this._lastkama = this._lastlastkama;
} else {
_lastkama = _lastlastkama;
}
else {
_buffer.Add(TValue.v);
_lastlastkama = _lastkama;
}
if (_buffer.Count > _p + 1) { _buffer.RemoveAt(0); }
double _kama = 0;
if (this.Count < this._p) {
for (int i = 0; i < this._buffer.Count; i++) { _kama += this._buffer[i]; }
_kama /= this._buffer.Count;
} else {
if (this.Count < this._p) { _kama = TValue.v; }
else {
double _change = Math.Abs(_buffer[_buffer.Count - 1] - _buffer[(_buffer.Count > _p + 1) ? 1 : 0]);
double _sumpv = 0;
for (int i = 1; i < _buffer.Count; i++)
@@ -58,8 +58,7 @@ public class KAMA_Series : Single_TSeries_Indicator
double _sc = (_er * (_scFast - _scSlow)) + _scSlow;
_kama = (_lastkama + (_sc * _sc * (TValue.v - _lastkama)));
}
_lastlastkama = _lastkama;
_lastkama = _kama;
base.Add((TValue.t, _kama), update, _NaN);
}
}
}
+2 -1
View File
@@ -21,7 +21,8 @@ public class SMA_Series : Single_TSeries_Indicator {
private int _len, _oldlen;
public SMA_Series(TSeries source, int period = 0, bool useNaN = false) : base(source, period, false) {
Reset();
_sum = _oldsum = 0;
_len = _oldlen = 0;
if (this._data.Count > 0) { base.Add(this._data); }
}
+4 -2
View File
@@ -26,13 +26,15 @@ public class ZLEMA_Series : Single_TSeries_Indicator
private readonly double _k, _k1m;
private double _lastema, _lastema_o;
private int _llag;
private readonly bool _useSMA;
public ZLEMA_Series(TSeries source, int period, bool useNaN = false) : base(source, period, useNaN)
public ZLEMA_Series(TSeries source, int period, bool useNaN = false, bool useSMA = true) : base(source, period, useNaN)
{
this._k = 2.0 / (this._p + 1);
this._k1m = 1.0 - this._k;
this._lastema = this._lastema_o = double.NaN;
_llag = (int)((_p-1) * 0.5);
_useSMA = useSMA;
if (_data.Count > 0) { base.Add(_data); }
}
@@ -47,7 +49,7 @@ public class ZLEMA_Series : Single_TSeries_Indicator
double _zl = TValue.v + (TValue.v - _data[_lag].v);
double _ema = 0;
if (this.Count < this._p) {
if (this.Count < this._p && _useSMA) {
Add_Replace_Trim(_buffer, _zl, _p, update);
_ema = _buffer.Average();
} else {