Documentation

This commit is contained in:
Miha Kralj
2022-12-26 20:12:56 -08:00
parent 3227cc1c55
commit 509bf244d9
43 changed files with 247 additions and 581 deletions
+24 -28
View File
@@ -2,38 +2,34 @@
using System;
/* <summary>
DWMA: Double (linearly) Weighted Moving Average
The weights are linearly decreasing over the period and the most recent data has
the heaviest weight.
Sources:
DWMA: Double Weighted Moving Average
The weights are decreasing over the period with p^2 decay
and the most recent data has the heaviest weight.
</summary> */
public class DWMA_Series : Single_TSeries_Indicator
{
public DWMA_Series(TSeries source, int period, bool useNaN = false) : base(source, period, useNaN)
{
for (int i = 0; i < this._p; i++) { this._weights.Add(i + 1); }
if (base._data.Count > 0) { base.Add(base._data); }
}
private readonly System.Collections.Generic.List<double> _buffer1 = new();
private readonly System.Collections.Generic.List<double> _buffer2 = new();
public class DWMA_Series : Single_TSeries_Indicator {
public DWMA_Series(TSeries source, int period, bool useNaN = false) : base(source, period, useNaN) {
for (int i = 0; i < this._p; i++) {
double _weight = (i + 1) * (i + 1);
this._weights.Add(_weight);
}
if (base._data.Count > 0) { base.Add(base._data); }
}
private readonly System.Collections.Generic.List<double> _buffer1 = new();
private readonly System.Collections.Generic.List<double> _weights = new();
public override void Add((System.DateTime t, double v) TValue, bool update)
{
Add_Replace_Trim(_buffer1, TValue.v, _p, update);
double _wma = 0;
for (int i = 0; i < _buffer1.Count; i++) { _wma += _buffer1[i] * this._weights[i]; }
_wma /= (this._buffer1.Count * (this._buffer1.Count + 1)) * 0.5;
public override void Add((System.DateTime t, double v) TValue, bool update) {
Add_Replace_Trim(_buffer1, TValue.v, _p, update);
double _wma1 = 0;
double _wsum = 0;
for (int i = 0; i < _buffer1.Count; i++) {
_wma1 += _buffer1[i] * this._weights[i];
_wsum += this._weights[i];
}
_wma1 /= _wsum;
Add_Replace_Trim(_buffer2, TValue.v, _p, update);
double _dwma = 0;
for (int i = 0; i < _buffer2.Count; i++) { _dwma += _buffer2[i] * this._weights[i]; }
_dwma /= (this._buffer2.Count * (this._buffer2.Count + 1)) * 0.5;
base.Add((TValue.t, 2*_wma - _dwma), update, _NaN);
}
base.Add((TValue.t, _wma1), update, _NaN);
}
}
+2 -2
View File
@@ -79,11 +79,11 @@ public class JMA_Series : Single_TSeries_Indicator {
//// from volty to avolty
if (update) { volty_10[volty_10.Count - 1] = volty; }
else { volty_10.Add(volty); }
if (volty_10.Count > _p) { volty_10.RemoveAt(0); }
if (volty_10.Count > 10) { volty_10.RemoveAt(0); }
vsum = prev_vsum + 0.1 * (volty - volty_10.First());
if (update) { vsum_buff[vsum_buff.Count - 1] = vsum; }
else { vsum_buff.Add(vsum); }
if (vsum_buff.Count > (65))
if (vsum_buff.Count > (10*_p))
vsum_buff.RemoveAt(0);
double avolty = 0;
for (int i = 0; i < vsum_buff.Count; i++) { avolty += vsum_buff[i]; }
+1 -1
View File
@@ -4,7 +4,7 @@ using System;
/* <summary>
SMA: Simple Moving Average
The weights are equally distributed across the period, resulting in a mean() of
the data within the period/
the data within the period
Sources:
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/simple-moving-average-sma/