From 509bf244d9ea775e0741f3e21624c14150a1b344 Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Mon, 26 Dec 2022 19:03:54 -0800 Subject: [PATCH 1/6] Documentation --- Source/Trends/DWMA_Series.cs | 52 +++--- Source/Trends/JMA_Series.cs | 4 +- Source/Trends/SMA_Series.cs | 2 +- Tests/Tests.csproj | 2 +- Tests/Validations/Trends/Pandas_TA.cs | 3 +- Tests/Validations/Trends/Skender.cs | 4 +- Tests/Validations/Trends/TA_LIB.cs | 6 +- Tests/Validations/Trends/Tulip.cs | 6 +- docs/ALMA.md | 5 + docs/DEMA.md | 5 + docs/DWMA.md | 5 + docs/EMA.md | 49 +++-- docs/HEMA.md | 4 + docs/HMA.md | 4 + docs/JMA.md | 4 + docs/KAMA.md | 4 + docs/RMA.md | 5 + docs/SMA.md | 58 +++--- docs/SMMA.md | 5 + docs/T3.md | 5 + docs/TEMA.md | 5 + docs/TRIMA.md | 5 + docs/WMA.md | 49 +++++ docs/ZLEMA.md | 5 + docs/_sidebar.md | 18 +- docs/img/ALMA_chart.svg | 1 + docs/img/DEMA_chart.svg | 1 + docs/img/DWMA_chart.svg | 1 + docs/img/EMA_chart.ipynb | 251 -------------------------- docs/img/HEMA_chart.svg | 1 + docs/img/HMA_chart.svg | 1 + docs/img/JMA_chart.svg | 1 + docs/img/KAMA_chart.svg | 1 + docs/img/MAMA_chart.svg | 1 + docs/img/RMA_chart.svg | 1 + docs/img/SMA_chart.ipynb | 242 ------------------------- docs/img/SMMA_chart.svg | 1 + docs/img/T3_chart.svg | 1 + docs/img/TEMA_chart.svg | 1 + docs/img/TRIMA_chart.svg | 1 + docs/img/WMA_chart.svg | 1 + docs/img/ZLEMA_chart.svg | 1 + docs/indicators.md | 6 +- 43 files changed, 247 insertions(+), 581 deletions(-) create mode 100644 docs/ALMA.md create mode 100644 docs/DEMA.md create mode 100644 docs/DWMA.md create mode 100644 docs/HEMA.md create mode 100644 docs/HMA.md create mode 100644 docs/JMA.md create mode 100644 docs/KAMA.md create mode 100644 docs/RMA.md create mode 100644 docs/SMMA.md create mode 100644 docs/T3.md create mode 100644 docs/TEMA.md create mode 100644 docs/TRIMA.md create mode 100644 docs/WMA.md create mode 100644 docs/ZLEMA.md create mode 100644 docs/img/ALMA_chart.svg create mode 100644 docs/img/DEMA_chart.svg create mode 100644 docs/img/DWMA_chart.svg delete mode 100644 docs/img/EMA_chart.ipynb create mode 100644 docs/img/HEMA_chart.svg create mode 100644 docs/img/HMA_chart.svg create mode 100644 docs/img/JMA_chart.svg create mode 100644 docs/img/KAMA_chart.svg create mode 100644 docs/img/MAMA_chart.svg create mode 100644 docs/img/RMA_chart.svg delete mode 100644 docs/img/SMA_chart.ipynb create mode 100644 docs/img/SMMA_chart.svg create mode 100644 docs/img/T3_chart.svg create mode 100644 docs/img/TEMA_chart.svg create mode 100644 docs/img/TRIMA_chart.svg create mode 100644 docs/img/WMA_chart.svg create mode 100644 docs/img/ZLEMA_chart.svg diff --git a/Source/Trends/DWMA_Series.cs b/Source/Trends/DWMA_Series.cs index 68eaf0bc..ebda7418 100644 --- a/Source/Trends/DWMA_Series.cs +++ b/Source/Trends/DWMA_Series.cs @@ -2,38 +2,34 @@ using System; /* -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. */ -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 _buffer1 = new(); - private readonly System.Collections.Generic.List _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 _buffer1 = new(); private readonly System.Collections.Generic.List _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); + } } \ No newline at end of file diff --git a/Source/Trends/JMA_Series.cs b/Source/Trends/JMA_Series.cs index 6a3f79fa..af37b43d 100644 --- a/Source/Trends/JMA_Series.cs +++ b/Source/Trends/JMA_Series.cs @@ -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]; } diff --git a/Source/Trends/SMA_Series.cs b/Source/Trends/SMA_Series.cs index d7a635a1..48e45ec4 100644 --- a/Source/Trends/SMA_Series.cs +++ b/Source/Trends/SMA_Series.cs @@ -4,7 +4,7 @@ using System; /* 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/ diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 35ebf49c..b770660d 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -18,7 +18,7 @@ - + diff --git a/Tests/Validations/Trends/Pandas_TA.cs b/Tests/Validations/Trends/Pandas_TA.cs index 78fc6055..5549a5c2 100644 --- a/Tests/Validations/Trends/Pandas_TA.cs +++ b/Tests/Validations/Trends/Pandas_TA.cs @@ -1,4 +1,3 @@ - using Xunit; using System; using QuanTAlib; @@ -392,4 +391,4 @@ public class PandasTA : IDisposable } } -} +} \ No newline at end of file diff --git a/Tests/Validations/Trends/Skender.cs b/Tests/Validations/Trends/Skender.cs index a5be0504..757acb07 100644 --- a/Tests/Validations/Trends/Skender.cs +++ b/Tests/Validations/Trends/Skender.cs @@ -414,7 +414,7 @@ public class Skender { T3_Series QL = new(source: bars.Close, period: period, vfactor: 0.7, false); var SK = quotes.GetT3(lookbackPeriods: period, volumeFactor: 0.7).Select(i => i.T3.Null2NaN()!); - for (int i = QL.Length; i > skip; i--) + for (int i = QL.Length; i > period*15; i--) { double QL_item = Math.Round(QL[i - 1].v, digits: digits); double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); @@ -425,7 +425,7 @@ public class Skender public void TRIX() { TRIX_Series QL = new(bars.Close, period, false); var SK = quotes.GetTrix(period).Select(i => i.Trix.Null2NaN()!); - for (int i = QL.Length; i > skip; i--) { + for (int i = QL.Length; i > period*12; i--) { double QL_item = Math.Round(QL[i - 1].v, digits: digits); double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits)); diff --git a/Tests/Validations/Trends/TA_LIB.cs b/Tests/Validations/Trends/TA_LIB.cs index 4464c333..0f34a472 100644 --- a/Tests/Validations/Trends/TA_LIB.cs +++ b/Tests/Validations/Trends/TA_LIB.cs @@ -141,7 +141,7 @@ public class Ta_Lib { DEMA_Series QL = new(bars.Close, period, false, useSMA: false); Core.Dema(inclose, 0, bars.Count - 1, TALIB, out int outBegIdx, out _, period); - for (int i = QL.Length - 1; i > skip*2; i--) + for (int i = QL.Length - 1; i > period*10; i--) { double QL_item = Math.Round(QL[i].v, digits: digits); double TA_item = Math.Round(TALIB[i - outBegIdx], digits: digits); @@ -397,7 +397,7 @@ public class Ta_Lib { T3_Series QL = new(source: bars.Close, period: period, vfactor: 0.7, useNaN: false); Core.T3(inReal: inclose, startIdx: 0, endIdx: bars.Count - 1, outReal: TALIB, outBegIdx: out int outBegIdx, outNbElement: out _, optInTimePeriod: period, optInVFactor: 0.7); - for (int i = QL.Length - 1; i > skip; i--) + for (int i = QL.Length - 1; i > period*10; i--) { double QL_item = Math.Round(QL[i].v, digits: digits); double TA_item = Math.Round(TALIB[i - outBegIdx], digits: digits); @@ -444,7 +444,7 @@ public class Ta_Lib public void TRIX() { TRIX_Series QL = new(bars.Close, period, useNaN: false, useSMA: true); Core.Trix(inclose, 0, bars.Count - 1, TALIB, out int outBegIdx, out _, period); - for (int i = QL.Length - 1; i > skip; i--) { + for (int i = QL.Length - 1; i > period*10; i--) { double QL_item = Math.Round(QL[i].v, digits: digits); double TA_item = Math.Round(TALIB[i - outBegIdx], digits: digits); Assert.InRange(TA_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); diff --git a/Tests/Validations/Trends/Tulip.cs b/Tests/Validations/Trends/Tulip.cs index 45b0665b..13a33ee0 100644 --- a/Tests/Validations/Trends/Tulip.cs +++ b/Tests/Validations/Trends/Tulip.cs @@ -442,11 +442,11 @@ public class Tulip_Test public void TRIX() { double[][] arrin = { inclose }; double[][] arrout = { outdata }; - TRIX_Series QL = new(bars.Close, period, false); + TRIX_Series QL = new(bars.Close, period); Tulip.Indicators.trix.Run(inputs: arrin, options: new double[] { period }, outputs: arrout); - for (int i = QL.Length - 1; i > skip; i--) { + for (int i = QL.Length - 1; i > period*10; i--) { double QL_item = QL[i].v; - double TU_item = arrout[0][i - period +1]; + double TU_item = arrout[0][i - (period*3) + 2]; Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } diff --git a/docs/ALMA.md b/docs/ALMA.md new file mode 100644 index 00000000..0aa250a0 --- /dev/null +++ b/docs/ALMA.md @@ -0,0 +1,5 @@ +# ALMA: Arnaud Legoux Moving Average + +period = 10 + +![Alt text](./img/ALMA_chart.svg) \ No newline at end of file diff --git a/docs/DEMA.md b/docs/DEMA.md new file mode 100644 index 00000000..e82d1ef9 --- /dev/null +++ b/docs/DEMA.md @@ -0,0 +1,5 @@ +# DEMA: Double Exponential Moving Average + +period = 10 + +![Alt text](./img/DEMA_chart.svg) \ No newline at end of file diff --git a/docs/DWMA.md b/docs/DWMA.md new file mode 100644 index 00000000..9ba59690 --- /dev/null +++ b/docs/DWMA.md @@ -0,0 +1,5 @@ +# DWMA: Double Weighted Moving Average + +period = 10 + +![Alt text](./img/DWMA_chart.svg) \ No newline at end of file diff --git a/docs/EMA.md b/docs/EMA.md index e372995e..f685351f 100644 --- a/docs/EMA.md +++ b/docs/EMA.md @@ -1,4 +1,7 @@ # EMA: Exponential Moving Average +period = 10 + +![Alt text](./img/EMA_chart.svg) EMA needs very short history buffer and calculates the EMA value using just the previous EMA value. The weight of the new datapoint (k) is k = 2 / (period-1) @@ -14,25 +17,33 @@ EMA_n = \left\{ \begin{array}{cl} $$ -## Implementation -``` csharp -EMA_Series mean = new(source: data, period: p, useNaN: false); +## Reference Calculation +period = 5 ``` - -- `TSeries source` - List of value tuples (DateTime, double) -- `int period` - Integer representing the period of SMA -- `bool useNaN` - if true, initial values from 1 to period-1 will be replaced with NaN. If false, the initial calculation will return values for SMA(length) instead of SMA(period) - -## Comparison & Validation - -Validation tests -Performance tests - -## Visual analysis - -![Alt text](./img/EMA_chart.svg) - - - +TSeries data = new() {81.59, 81.06, 82.87, 83.00, 83.61, 83.15, 82.84, 83.99, 84.55, 84.36, 85.53, 86.54, 86.89, 87.77, 87.29}; +EMA_Series ema = new(data, 5, useNaN: false); +EMA_Series ema_nan = new(data, 5, useNaN: true); +for (int i=0; i< data.Count; i++) + Console.WriteLine($"{i}\t{data[i].v,7:f2}\t{ema_nan[i].v,7:f3}\t{ema[i].v,7:f3}"); +``` +|#|input|ema_NaN|ema| +|--|:--:|:--:|:--:| +|0| 81.59| NaN| 81.590| +|1| 81.06| NaN| 81.325| +|2| 82.87| NaN| 81.840| +|3| 83.00| NaN| 82.130| +|4| 83.61| 82.426| 82.426| +|5| 83.15| 82.667| 82.667| +|6| 82.84| 82.725| 82.725| +|7| 83.99| 83.147| 83.147| +|8| 84.55| 83.614| 83.614| +|9| 84.36| 83.863| 83.863| +|10| 85.53| 84.419| 84.419| +|11| 86.54| 85.126| 85.126| +|12| 86.89| 85.714| 85.714| +|13| 87.77| 86.399| 86.399| +|14| 87.29| 86.696| 86.696| ## References + +- https://en.wikipedia.org/wiki/Exponential_smoothing \ No newline at end of file diff --git a/docs/HEMA.md b/docs/HEMA.md new file mode 100644 index 00000000..5ede117a --- /dev/null +++ b/docs/HEMA.md @@ -0,0 +1,4 @@ +# HEMA: Hull-Exponential Moving Average +period = 10 + +![Alt text](./img/HEMA_chart.svg) \ No newline at end of file diff --git a/docs/HMA.md b/docs/HMA.md new file mode 100644 index 00000000..22761879 --- /dev/null +++ b/docs/HMA.md @@ -0,0 +1,4 @@ +# HMA: Hull Moving Average +period = 10 + +![Alt text](./img/HMA_chart.svg) \ No newline at end of file diff --git a/docs/JMA.md b/docs/JMA.md new file mode 100644 index 00000000..31c7de3e --- /dev/null +++ b/docs/JMA.md @@ -0,0 +1,4 @@ +# JMA: Jurik Moving Average +period = 10 + +![Alt text](./img/JMA_chart.svg) \ No newline at end of file diff --git a/docs/KAMA.md b/docs/KAMA.md new file mode 100644 index 00000000..594d4d10 --- /dev/null +++ b/docs/KAMA.md @@ -0,0 +1,4 @@ +# KAMA: Kaufman's Adaptive Moving Average +period = 10 + +![Alt text](./img/KAMA_chart.svg) \ No newline at end of file diff --git a/docs/RMA.md b/docs/RMA.md new file mode 100644 index 00000000..e33234d9 --- /dev/null +++ b/docs/RMA.md @@ -0,0 +1,5 @@ +# RMA: wildeR Moving Average + +period = 10 + +![Alt text](./img/RMA_chart.svg) \ No newline at end of file diff --git a/docs/SMA.md b/docs/SMA.md index 409e4c3e..8a1d0707 100644 --- a/docs/SMA.md +++ b/docs/SMA.md @@ -1,39 +1,51 @@ -![Alt text](./img/SMA_chart.svg) # SMA: Simple Moving Average -SMA is one of the most basic trend-following indicators used in Technical Analysis. It is calculated as the *unweighted mean* of the previous $p$ (period) data-points. +period = 10 + +![Alt text](./img/SMA_chart.svg) + +SMA is is an arithmetic moving average where the weights in SMA are **equally** distributed across the given period, resulting in a mean() of the data within the period. ## Calculation -SMA is a rolling calculation looking backwards from the position ${n}$ and is denoted as ${SMA}_{p}{(data)}$ where $p$ represents the period and $data$ represents the list of data points: +SMA is a rolling calculation that is looking backwards from the position ${n}$ and is denoted as ${SMA}_{p}{(data)}$ where $p$ represents the period and $data$ represents the list of data points: $$ SMA_p{(data)} = \frac{1}{p}\sum_{i=n-p+1}^{n} data_i $$ -When calculating the value of next $SMA_{p,next}$ while knowing all previous SMA values, SMA calculation can be reduced to: +When calculating the value of the next $SMA_{p,next}$ while knowing all previous SMA values, SMA calculation can be reduced to: $$ SMA_{p,next} = SMA_{p,prev}+\frac{1}{p}\left( data_{n+1}-data_{n+1-p}\right) $$ -## Implementation - -``` csharp -SMA_Series mean = new(source: data, period: p, useNaN: false); +## Reference Calculation +period = 5 +``` +TSeries data = new() {81.59, 81.06, 82.87, 83.00, 83.61, 83.15, 82.84, 83.99, 84.55, 84.36, 85.53, 86.54, 86.89, 87.77, 87.29}; +SMA_Series sma = new(data, 5, useNaN: false); +SMA_Series sma_nan = new(data, 5, useNaN: true); +for (int i=0; i< data.Count; i++) + Console.WriteLine($"{i}\t{data[i].v,7:f2}\t{sma_nan[i].v,7:f3}\t{sma[i].v,7:f3}"); ``` -- `TSeries source` - List of value tuples (DateTime, double) -- `int period` - Integer representing the period of SMA -- `bool useNaN` - if true, initial values from 1 to period-1 will be replaced with NaN. If false, the initial calculation will return values for SMA(length) instead of SMA(period) - -## Comparison & Validation - -Validation tests -Performance tests - -## Visual analysis - - - - +|#|input|sma_NaN|sma| +|--|:--:|:--:|:--:| +|0| 81.59| NaN| 81.590| +|1| 81.06| NaN| 81.325| +|2| 82.87| NaN| 81.840| +|3| 83.00| NaN| 82.130| +|4| 83.61| 82.426| 82.426| +|5| 83.15| 82.738| 82.738| +|6| 82.84| 83.094| 83.094| +|7| 83.99| 83.318| 83.318| +|8| 84.55| 83.628| 83.628| +|9| 84.36| 83.778| 83.778| +|10| 85.53| 84.254| 84.254| +|11| 86.54| 84.994| 84.994| +|12| 86.89| 85.574| 85.574| +|13| 87.77| 86.218| 86.218| +|14| 87.29| 86.804| 86.804| ## References - - https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/simple-moving-average-sma/ \ No newline at end of file + - https://en.wikipedia.org/wiki/Moving_average#Simple_moving_average + - Kaufman, Perry J. (2013) Trading Systems and Methods + - Murphy, J. (1999) Technical Analysis of the Financial Markets \ No newline at end of file diff --git a/docs/SMMA.md b/docs/SMMA.md new file mode 100644 index 00000000..9d5946f4 --- /dev/null +++ b/docs/SMMA.md @@ -0,0 +1,5 @@ +# SMMA: Smoothed Moving Average + +period = 10 + +![Alt text](./img/SMMA_chart.svg) \ No newline at end of file diff --git a/docs/T3.md b/docs/T3.md new file mode 100644 index 00000000..ae8f7082 --- /dev/null +++ b/docs/T3.md @@ -0,0 +1,5 @@ +# T3: Tillson T3 Moving Average + +period = 10 + +![Alt text](./img/T3_chart.svg) \ No newline at end of file diff --git a/docs/TEMA.md b/docs/TEMA.md new file mode 100644 index 00000000..1d79871e --- /dev/null +++ b/docs/TEMA.md @@ -0,0 +1,5 @@ +# TEMA: Triple Exponential Moving Average + +period = 10 + +![Alt text](./img/TEMA_chart.svg) \ No newline at end of file diff --git a/docs/TRIMA.md b/docs/TRIMA.md new file mode 100644 index 00000000..712eefb1 --- /dev/null +++ b/docs/TRIMA.md @@ -0,0 +1,5 @@ +# TRIMA: Triangular Moving Average + +period = 10 + +![Alt text](./img/TRIMA_chart.svg) \ No newline at end of file diff --git a/docs/WMA.md b/docs/WMA.md new file mode 100644 index 00000000..42792053 --- /dev/null +++ b/docs/WMA.md @@ -0,0 +1,49 @@ +# WMA: Weighted Moving Average +period = 10 + +![Alt text](./img/WMA_chart.svg) + +WMA is linearly weighted moving Average where the weights are linearly decreasing over the _period_ and the most recent data has the heaviest weight. + +## Calculation + +WMA is a rolling calculation that is looking backwards from the position ${n}$ and is denoted as ${WMA}_{p}{(data)}$ where $p$ represents the period, $w$ represents the assigned weight and $data$ represents the list of data points: +$$ +WMA_p{(data)} = \frac{1}{\sum w }\sum_{i=n-p+1}^{n} w_i data_i +$$ +Weights $w$ are linearly increasing from $1$ to $p$. For example, the weights $w$ for a $p=5$ would be {1, 2, 3, 4, 5} + + + +## Reference Calculation +period = 5 +``` +TSeries data = new() {81.59, 81.06, 82.87, 83.00, 83.61, 83.15, 82.84, 83.99, 84.55, 84.36, 85.53, 86.54, 86.89, 87.77, 87.29}; +WMA_Series wma = new(data, 5, useNaN: false); +WMA_Series wma_nan = new(data, 5, useNaN: true); +for (int i=0; i< data.Count; i++) + Console.WriteLine($"{i}\t{data[i].v,7:f2}\t{wma_nan[i].v,7:f3}\t{wma[i].v,7:f3}"); +``` + +|#|input|wma_NaN|wma| +|--|:--:|:--:|:--:| +|0| 81.59| NaN| 81.590| +|1| 81.06| NaN| 81.237| +|2| 82.87| NaN| 82.053| +|3| 83.00| NaN| 82.432| +|4| 83.61| 82.825| 82.825| +|5| 83.15| 83.066| 83.066| +|6| 82.84| 83.100| 83.100| +|7| 83.99| 83.399| 83.399| +|8| 84.55| 83.809| 83.809| +|9| 84.36| 84.053| 84.053| +|10| 85.53| 84.637| 84.637| +|11| 86.54| 85.399| 85.399| +|12| 86.89| 86.031| 86.031| +|13| 87.77| 86.763| 86.763| +|14| 87.29| 87.121| 87.121| + +## References + - https://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average + - Kaufman, Perry J. (2013) Trading Systems and Methods + - Murphy, J. (1999) Technical Analysis of the Financial Markets \ No newline at end of file diff --git a/docs/ZLEMA.md b/docs/ZLEMA.md new file mode 100644 index 00000000..5df16918 --- /dev/null +++ b/docs/ZLEMA.md @@ -0,0 +1,5 @@ +# ZLEMA: Zero-lag Exponential Moving Average + +period = 10 + +![Alt text](./img/ZLEMA_chart.svg) \ No newline at end of file diff --git a/docs/_sidebar.md b/docs/_sidebar.md index c124b2be..52a8a6dd 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -2,4 +2,20 @@ * [List of all Indicators](indicators.md "Indicators coverage") - * [EMA - Exponential Moving Average](EMA.md "EMA - Exponential Moving Average") + * [SMA - Simple Moving Average](SMA.md) + * [RMA - WildeR Moving Average](RMA.md) + * [EMA - Exponential Moving Average](EMA.md) + * [WMA - Weighted Moving Average](WMA.md) + * [SMMA - Smoothed Moving Average](SMMA.md) + * [DWMA - Double Weighted Moving Average](DWMA.md) + * [TRIMA - Triangular Moving Average](TRIMA.md) + * [DEMA - Double Exponential MA](DEMA.md) + * [TEMA - Triple Exponential MA](TEMA.md) + * [T3 - Tillson T3 Exponential MA](T3.md) + * [HMA - Hull Moving Average](HMA.md) + * [HEMA - Hull/Exponential Moving Average](HEMA.md) + * [KAMA - Kaufman Adaptive Moving Average](KAMA.md) + * [ALMA - Arnaud Legoux Moving Average](ALMA.md) + * [ZLEMA - Zero-Lag Exponential MA](ZLEMA.md) + * [JMA - Jurik Moving Average](JMA.md) + diff --git a/docs/img/ALMA_chart.svg b/docs/img/ALMA_chart.svg new file mode 100644 index 00000000..2e3ef221 --- /dev/null +++ b/docs/img/ALMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/DEMA_chart.svg b/docs/img/DEMA_chart.svg new file mode 100644 index 00000000..16913aa6 --- /dev/null +++ b/docs/img/DEMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/DWMA_chart.svg b/docs/img/DWMA_chart.svg new file mode 100644 index 00000000..2ed01660 --- /dev/null +++ b/docs/img/DWMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/EMA_chart.ipynb b/docs/img/EMA_chart.ipynb deleted file mode 100644 index baa2b861..00000000 --- a/docs/img/EMA_chart.ipynb +++ /dev/null @@ -1,251 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "Loading extensions from `C:\\Users\\miha\\.nuget\\packages\\plotly.net.interactive\\3.0.2\\interactive-extensions\\dotnet\\Plotly.NET.Interactive.dll`" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "//#r \"nuget: QuanTAlib;\"\n", - "\n", - "#r \"nuget: Plotly.NET;\"\n", - "#r \"nuget: Plotly.NET.Interactive;\"\n", - "#r \"nuget: Plotly.NET.ImageExport;\"\n", - "#r \"..\\..\\Source\\bin\\Debug\\net6.0\\QuanTAlib.dll\"\n", - "\n", - "using QuanTAlib;\n", - "using Plotly.NET;\n", - "using Plotly.NET.LayoutObjects;\n", - "using Plotly.NET.ImageExport;" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - }, - "polyglot_notebook": { - "kernelName": "csharp" - } - }, - "outputs": [], - "source": [ - "TSeries d1a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\n", - "TSeries d2a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};\n", - "TSeries d3a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\n", - "TSeries d4a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2};\n", - "TSeries d5a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0.32,0.56,0.72,0.84,0.93,0.99,1,0.97,0.91,0.81,0.68,0.52,0.33,0.14,-0.06,-0.26,-0.44,-0.61,-0.76,-0.87,-0.95,-0.99,-1,-0.96,-0.88,-0.77,-0.63,-0.46,-0.28,-0.08,0.12,0.31,0.49,0.66,0.79,0.9,0.97,1,0.99,0.94,0.85,0.73,0.58,0.41,0.22,0.02,-0.17,-0.37,-0.54,-0.7,-0.83,-0.92,-0.98,-1,-0.98,-0.92,-0.82,-0.69,-0.54,-0.36,-0.17,0.03,0.23,0.42,0.59,0.74};\n", - "TSeries d6a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1};\n", - "TSeries d7a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0.93,0.27,-0.59,-1,-0.71,0.05,0.75,1,0.67,0,-0.67,-0.99,-0.85,-0.34,0.31,0.81,1,0.82,0.35,-0.22,-0.71,-0.98,-0.95,-0.66,-0.2,0.31,0.72,0.96,0.98,0.78,0.43,-0.01,-0.43,-0.77,-0.96,-0.99,-0.85,-0.58,-0.23,0.16,0.51,0.79,0.95,1,0.92,0.73,0.47,0.15,-0.17,-0.47,-0.72,-0.9,-0.99,-0.99,-0.9,-0.74,-0.52,-0.26,0.01,0.28,0.53,0.73,0.88,0.97,1,0.97};\n", - "TSeries d8a = new() {-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,0.03,-0.4,-0.47,0.19,-0.4,-0.23,0.31,0.41,0.19,0.16,-0.5,-0.31,-0.21,0.25,0.18,-0.48,-0.1,0.38,0.29,-0.38,-0.08,-0.21,0.34,0.01,-0.46,0.28,-0.48,0.11,0.02,-0.37,0.19,-0.2,0.1,0.24,0.08,-0.22,-0.12,0.15,0.36,-0.43,-0.03,-0.32,0.45,-0.5,-0.04,-0.04,-0.08,-0.18,0.13,-0.33,-0.19,0.36,-0.39,0.2,-0.31,0.28,-0.13,-0.07,-0.29,0.37,0.03,-0.25,-0.06,-0.3,-0.08,-0.09};\n", - "TSeries d9a = new() {-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,0,0.03,0.11,-0.1,-0.43,-0.08,0.36,-0.04,-0.04,-0.21,-0.3,0.26,0.2,0.28,0.2,0.27,-0.01,-0.1,-0.23,-0.13,-0.41,-0.23,-0.07,-0.21,0.32,-0.18,-0.48,0.3,0.46,-0.2,0.52,-0.81,-0.25,-0.21,-0.12,-0.18,0.18,0.52,0.29,0.44,0.18,-1.2,0.38,0.24,0.06,0.28,0.34,0.3,-0.13,0.19,-0.5,0.59,-0.36,0.22,-0.23,0.24,0.39,0.13,-0.33,-0.57,-0.23,0.49,-0.13,0.76,0.59,0.61};\n", - "TSeries d10a = new() {-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0,-0.28,0.41,-0.54,0.65,-0.75,0.84,-0.91,0.96,-0.99,1,-0.99,0.96,-0.92,0.85,-0.77,0.67,-0.56,0.44,-0.3,0.17,-0.03,-0.11,0.25,-0.39,0.51,-0.63,0.73,-0.82,0.89,-0.95,0.98,-1,0.99,-0.97,0.93,-0.86,0.78,-0.69,0.58,-0.46,0.33,-0.19,0.05,0.09,-0.23,0.36,-0.49,0.61,-0.71,0.81,-0.88,0.94,-0.98,1,-1,0.98,-0.94,0.88,-0.8,0.71,-0.6,0.48,-0.35,0.22,-0.08,-0.06};\n", - "TSeries d11a = new() {-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,0,0.14,-0.76,-0.96,-0.28,0.66,0.99,0.41,-0.54,-1,-0.54,0.42,0.99,0.65,-0.29,-0.96,-0.75,0.15,0.91,0.84,-0.01,-0.85,-0.91,-0.13,0.76,0.96,0.27,-0.66,-0.99,-0.4,0.55,1,0.53,-0.43,-0.99,-0.64,0.3,0.96,0.75,-0.16,-0.92,-0.83,0.02,0.85,0.9,0.12,-0.77,-0.95,-0.26,0.67,0.99,0.4,-0.56,-1,-0.52,0.44,0.99,0.64,-0.3,-0.97,-0.74,0.17,0.92,0.83,-0.03,-0.86};\n", - "TSeries d12a = new() {-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0,0,0.05,-0.25,-0.32,-0.09,0.22,0.33,0.14,-0.18,-0.33,-0.18,0.14,0.33,0.22,-0.1,-0.32,-0.25,0.05,0.3,0.28,0,-0.28,-0.3,-0.04,0.25,0.32,0.09,-0.22,-0.33,-0.13,0.18,0.33,0.18,0.86,0.67,0.79,1.1,1.32,1.25,0.95,0.69,0.72,1.01,1.28,1.3,1.04,0.74,0.68,0.91,1.22,1.33,1.13,0.81,0.67,0.83,1.15,1.33,1.21,0.9,0.68,0.75,1.06,1.31,1.28,0.99,0.71};\n", - "TSeries d13a = new() {-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0,0,2.7,-0.8,-0.8,3.6,9.3,11.95,10.05,6.3,5,8.3,14.1,17.95,17.25,13.55,11.2,13.25,18.75,23.55,24.2,20.95,17.75,18.45,23.35,28.8,30.8,28.35,24.7,24.05,28,33.75,37,35.65,31.85,28.05,-3.2,1.5,4.8,3.75,-0.8,-4.6,-4.15,0.1,4.25,4.5,0.6,-3.85,-4.75,-1.3,3.35,4.95,2,-2.8,-5,-2.6,2.2,4.95,3.2,-1.5,-4.85,-3.7,0.85,4.6,4.15,-0.15,-4.3};\n", - "TSeries d14a = new() {-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0,0,0.59,0.83,0.74,0.5,0.91,1.36,0.93,0.87,0.6,0.38,0.78,0.53,0.42,0.14,0.01,-0.45,-0.71,-0.99,-1,-1.36,-1.22,-1.07,-1.17,-0.56,-0.95,-1.11,-0.16,0.18,-0.28,0.64,-0.5,0.24,0.45,0.67,0.72,1.15,1.52,1.28,1.38,1.03,-0.47,0.96,0.65,0.28,0.3,0.17,-0.07,-0.67,-0.51,-1.33,-0.33,-1.34,-0.78,-1.21,-0.68,-0.43,-0.56,-0.87,-0.93,-0.4,0.52,0.1,1.18,1.18,1.35};\n", - "TSeries d15a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,1.3,0.3,-0.48,-1.1,-1.14,-0.03,1.11,0.96,0.63,-0.21,-0.97,-0.73,-0.65,-0.06,0.51,1.08,0.99,0.72,0.12,-0.35,-1.12,-1.21,-1.02,-0.87,0.12,0.13,0.24,1.26,1.44,0.58,0.95,-0.82,-0.68,-0.98,-1.08,-1.17,-0.67,-0.06,0.06,0.6,0.69,-0.41,1.33,1.24,0.98,1.01,0.81,0.45,-0.3,-0.28,-1.22,-0.31,-1.35,-0.77,-1.13,-0.5,-0.13,-0.13,-0.32,-0.29,0.3,1.22,0.75,1.73,1.59,1.58};\n", - "TSeries d16a = new() {175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.44,176.27,176.04,176.99,175.49,175.68,174.34,176.4,174.05,174.4,174.2,176.16,175,177.72,174.33,176.96,174.62,174.76,170.9,171.12,171.05,170.01,169.24,172.64,171.96,175.72,174.16,175.81,177.3,178.38,176.75,177.19,175.55,178.49,176.52,178.45,178.04,178.25,177.8,176.97,172.94,174.92,173.98,172.29,171.19,172.54,172.11,175.32,175.63,176.65,173.8,176.04,172.74,175.24,171.84,171.54,172.17,171.85,172.38,170.78,173.49,173.69,171.71,174.38,173.99,174.83};" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - }, - "polyglot_notebook": { - "kernelName": "csharp" - } - }, - "outputs": [], - "source": [ - "int period = 10;\n", - "int cut = 26;\n", - "\n", - "EMA_Series d1b = new(d1a, period);\n", - "EMA_Series d2b = new(d2a, period);\n", - "EMA_Series d3b = new(d3a, period);\n", - "EMA_Series d4b = new(d4a, period);\n", - "EMA_Series d5b = new(d5a, period);\n", - "EMA_Series d6b = new(d6a, period);\n", - "EMA_Series d7b = new(d7a, period);\n", - "EMA_Series d8b = new(d8a, period);\n", - "EMA_Series d9b = new(d9a, period);\n", - "EMA_Series d10b = new(d10a, period);\n", - "EMA_Series d11b = new(d11a, period);\n", - "EMA_Series d12b = new(d12a, period);\n", - "EMA_Series d13b = new(d13a, period);\n", - "EMA_Series d14b = new(d14a, period);\n", - "EMA_Series d15b = new(d15a, period);\n", - "EMA_Series d16b = new(d16a, period);\n", - "\n", - "List x = Enumerable.Range(-cut,96).ToList();\n", - "GenericChart.GenericChart ch1a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d1a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch1b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d1b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch2a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d2a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch2b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d2b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch3a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d3a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch3b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d3b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch4a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d4a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch4b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d4b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch5a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d5a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch5b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d5b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch6a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d6a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch6b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d6b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch7a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d7a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch7b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d7b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch8a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d8a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch8b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d8b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch9a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d9a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch9b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d9b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch10a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d10a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch10b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d10b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch11a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d11a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch11b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d11b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch12a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d12a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch12b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d12b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch13a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d13a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch13b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d13b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch14a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d14a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch14b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d14b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch15a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d15a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch15b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d15b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch16a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d16a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch16b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d16b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "\n", - "var ch1 = Chart.Combine(new []{ch1a,ch1b});\n", - "var ch2 = Chart.Combine(new []{ch2a,ch2b});\n", - "var ch3 = Chart.Combine(new []{ch3a,ch3b});\n", - "var ch4 = Chart.Combine(new []{ch4a,ch4b});\n", - "var ch5 = Chart.Combine(new []{ch5a,ch5b});\n", - "var ch6 = Chart.Combine(new []{ch6a,ch6b});\n", - "var ch7 = Chart.Combine(new []{ch7a,ch7b});\n", - "var ch8 = Chart.Combine(new []{ch8a,ch8b});\n", - "var ch9 = Chart.Combine(new []{ch9a,ch9b});\n", - "var ch10 = Chart.Combine(new []{ch10a,ch10b});\n", - "var ch11 = Chart.Combine(new []{ch11a,ch11b});\n", - "var ch12 = Chart.Combine(new []{ch12a,ch12b});\n", - "var ch13 = Chart.Combine(new []{ch13a,ch13b});\n", - "var ch14 = Chart.Combine(new []{ch14a,ch14b});\n", - "var ch15 = Chart.Combine(new []{ch15a,ch15b});\n", - "var ch16 = Chart.Combine(new []{ch16a,ch16b});\n", - "\n", - "Layout layout = new Layout(); layout.SetValue(\"showlegend\",false);\n", - "var chart1 = new []{ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9,ch10,ch11,ch12,ch13,ch14,ch15,ch16};\n", - "var full = Chart.Grid>(8,2).Invoke(chart1).WithSize(1000,2200).WithMargin(Margin.init(30,20,20,30,7,false)).WithLayout(layout);\n", - "full.SaveSVG(\"EMA_chart\", Width: 1000, Height: 2200);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".NET (C#)", - "language": "C#", - "name": ".net-csharp" - }, - "polyglot_notebook": { - "kernelInfo": { - "defaultKernelName": "csharp", - "items": [ - { - "aliases": [ - "c#", - "C#" - ], - "languageName": "C#", - "name": "csharp" - }, - { - "aliases": [], - "name": ".NET" - }, - { - "aliases": [ - "f#", - "F#" - ], - "languageName": "F#", - "name": "fsharp" - }, - { - "aliases": [], - "languageName": "HTML", - "name": "html" - }, - { - "aliases": [], - "languageName": "KQL", - "name": "kql" - }, - { - "aliases": [], - "languageName": "Mermaid", - "name": "mermaid" - }, - { - "aliases": [ - "powershell" - ], - "languageName": "PowerShell", - "name": "pwsh" - }, - { - "aliases": [], - "languageName": "SQL", - "name": "sql" - }, - { - "aliases": [], - "name": "value" - }, - { - "aliases": [ - "frontend" - ], - "name": "vscode" - }, - { - "aliases": [ - "js" - ], - "languageName": "JavaScript", - "name": "javascript" - }, - { - "aliases": [], - "name": "webview" - } - ] - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/img/HEMA_chart.svg b/docs/img/HEMA_chart.svg new file mode 100644 index 00000000..ed35c54f --- /dev/null +++ b/docs/img/HEMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1010204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.511.50204060−1001020300204060−1010204060−10120204060170172174176178 \ No newline at end of file diff --git a/docs/img/HMA_chart.svg b/docs/img/HMA_chart.svg new file mode 100644 index 00000000..7fa9c1b1 --- /dev/null +++ b/docs/img/HMA_chart.svg @@ -0,0 +1 @@ +020406000.51020406000.510204060−100102030020406001020300204060−1−0.500.510204060−1010204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−10120204060170172174176178 \ No newline at end of file diff --git a/docs/img/JMA_chart.svg b/docs/img/JMA_chart.svg new file mode 100644 index 00000000..4be3d13e --- /dev/null +++ b/docs/img/JMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/KAMA_chart.svg b/docs/img/KAMA_chart.svg new file mode 100644 index 00000000..2ed53b3a --- /dev/null +++ b/docs/img/KAMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/MAMA_chart.svg b/docs/img/MAMA_chart.svg new file mode 100644 index 00000000..3a17f18e --- /dev/null +++ b/docs/img/MAMA_chart.svg @@ -0,0 +1 @@ +020406000.5×10​621×10​62020406002×10​594×10​596×10​598×10​590204060−3×10​45−2×10​45−1×10​450020406001×10​402×10​400204060−1.5×10​19−1×10​19−0.5×10​1900204060−5×10​3805×10​380204060−5×10​2205×10​22020406001×10​482×10​48020406000.5×10​331×10​331.5×10​33020406001×10​692×10​693×10​694×10​690204060−1×10​37−0.5×10​3700204060−1×10​34−0.5×10​3400204060−3×10​33−2×10​33−1×10​3300204060−1×10​28−0.5×10​280020406002×10​244×10​246×10​24020406002×10​224×10​226×10​22 \ No newline at end of file diff --git a/docs/img/RMA_chart.svg b/docs/img/RMA_chart.svg new file mode 100644 index 00000000..3be85be9 --- /dev/null +++ b/docs/img/RMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/SMA_chart.ipynb b/docs/img/SMA_chart.ipynb deleted file mode 100644 index 5d631e45..00000000 --- a/docs/img/SMA_chart.ipynb +++ /dev/null @@ -1,242 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "//#r \"nuget: QuanTAlib;\"\n", - "\n", - "#r \"nuget: Plotly.NET;\"\n", - "#r \"nuget: Plotly.NET.Interactive;\"\n", - "#r \"nuget: Plotly.NET.ImageExport;\"\n", - "#r \"..\\..\\Source\\bin\\Debug\\net6.0\\QuanTAlib.dll\"\n", - "\n", - "using QuanTAlib;\n", - "using Plotly.NET;\n", - "using Plotly.NET.LayoutObjects;\n", - "using Plotly.NET.ImageExport;" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - }, - "polyglot_notebook": { - "kernelName": "csharp" - } - }, - "outputs": [], - "source": [ - "TSeries d1a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\n", - "TSeries d2a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};\n", - "TSeries d3a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\n", - "TSeries d4a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2};\n", - "TSeries d5a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0.32,0.56,0.72,0.84,0.93,0.99,1,0.97,0.91,0.81,0.68,0.52,0.33,0.14,-0.06,-0.26,-0.44,-0.61,-0.76,-0.87,-0.95,-0.99,-1,-0.96,-0.88,-0.77,-0.63,-0.46,-0.28,-0.08,0.12,0.31,0.49,0.66,0.79,0.9,0.97,1,0.99,0.94,0.85,0.73,0.58,0.41,0.22,0.02,-0.17,-0.37,-0.54,-0.7,-0.83,-0.92,-0.98,-1,-0.98,-0.92,-0.82,-0.69,-0.54,-0.36,-0.17,0.03,0.23,0.42,0.59,0.74};\n", - "TSeries d6a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1};\n", - "TSeries d7a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0.93,0.27,-0.59,-1,-0.71,0.05,0.75,1,0.67,0,-0.67,-0.99,-0.85,-0.34,0.31,0.81,1,0.82,0.35,-0.22,-0.71,-0.98,-0.95,-0.66,-0.2,0.31,0.72,0.96,0.98,0.78,0.43,-0.01,-0.43,-0.77,-0.96,-0.99,-0.85,-0.58,-0.23,0.16,0.51,0.79,0.95,1,0.92,0.73,0.47,0.15,-0.17,-0.47,-0.72,-0.9,-0.99,-0.99,-0.9,-0.74,-0.52,-0.26,0.01,0.28,0.53,0.73,0.88,0.97,1,0.97};\n", - "TSeries d8a = new() {-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,0.03,-0.4,-0.47,0.19,-0.4,-0.23,0.31,0.41,0.19,0.16,-0.5,-0.31,-0.21,0.25,0.18,-0.48,-0.1,0.38,0.29,-0.38,-0.08,-0.21,0.34,0.01,-0.46,0.28,-0.48,0.11,0.02,-0.37,0.19,-0.2,0.1,0.24,0.08,-0.22,-0.12,0.15,0.36,-0.43,-0.03,-0.32,0.45,-0.5,-0.04,-0.04,-0.08,-0.18,0.13,-0.33,-0.19,0.36,-0.39,0.2,-0.31,0.28,-0.13,-0.07,-0.29,0.37,0.03,-0.25,-0.06,-0.3,-0.08,-0.09};\n", - "TSeries d9a = new() {-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,0,0.03,0.11,-0.1,-0.43,-0.08,0.36,-0.04,-0.04,-0.21,-0.3,0.26,0.2,0.28,0.2,0.27,-0.01,-0.1,-0.23,-0.13,-0.41,-0.23,-0.07,-0.21,0.32,-0.18,-0.48,0.3,0.46,-0.2,0.52,-0.81,-0.25,-0.21,-0.12,-0.18,0.18,0.52,0.29,0.44,0.18,-1.2,0.38,0.24,0.06,0.28,0.34,0.3,-0.13,0.19,-0.5,0.59,-0.36,0.22,-0.23,0.24,0.39,0.13,-0.33,-0.57,-0.23,0.49,-0.13,0.76,0.59,0.61};\n", - "TSeries d10a = new() {-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0.4,-0.4,0,-0.28,0.41,-0.54,0.65,-0.75,0.84,-0.91,0.96,-0.99,1,-0.99,0.96,-0.92,0.85,-0.77,0.67,-0.56,0.44,-0.3,0.17,-0.03,-0.11,0.25,-0.39,0.51,-0.63,0.73,-0.82,0.89,-0.95,0.98,-1,0.99,-0.97,0.93,-0.86,0.78,-0.69,0.58,-0.46,0.33,-0.19,0.05,0.09,-0.23,0.36,-0.49,0.61,-0.71,0.81,-0.88,0.94,-0.98,1,-1,0.98,-0.94,0.88,-0.8,0.71,-0.6,0.48,-0.35,0.22,-0.08,-0.06};\n", - "TSeries d11a = new() {-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,-0.6,0.6,0,0.14,-0.76,-0.96,-0.28,0.66,0.99,0.41,-0.54,-1,-0.54,0.42,0.99,0.65,-0.29,-0.96,-0.75,0.15,0.91,0.84,-0.01,-0.85,-0.91,-0.13,0.76,0.96,0.27,-0.66,-0.99,-0.4,0.55,1,0.53,-0.43,-0.99,-0.64,0.3,0.96,0.75,-0.16,-0.92,-0.83,0.02,0.85,0.9,0.12,-0.77,-0.95,-0.26,0.67,0.99,0.4,-0.56,-1,-0.52,0.44,0.99,0.64,-0.3,-0.97,-0.74,0.17,0.92,0.83,-0.03,-0.86};\n", - "TSeries d12a = new() {-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0,0,0.05,-0.25,-0.32,-0.09,0.22,0.33,0.14,-0.18,-0.33,-0.18,0.14,0.33,0.22,-0.1,-0.32,-0.25,0.05,0.3,0.28,0,-0.28,-0.3,-0.04,0.25,0.32,0.09,-0.22,-0.33,-0.13,0.18,0.33,0.18,0.86,0.67,0.79,1.1,1.32,1.25,0.95,0.69,0.72,1.01,1.28,1.3,1.04,0.74,0.68,0.91,1.22,1.33,1.13,0.81,0.67,0.83,1.15,1.33,1.21,0.9,0.68,0.75,1.06,1.31,1.28,0.99,0.71};\n", - "TSeries d13a = new() {-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0,0,2.7,-0.8,-0.8,3.6,9.3,11.95,10.05,6.3,5,8.3,14.1,17.95,17.25,13.55,11.2,13.25,18.75,23.55,24.2,20.95,17.75,18.45,23.35,28.8,30.8,28.35,24.7,24.05,28,33.75,37,35.65,31.85,28.05,-3.2,1.5,4.8,3.75,-0.8,-4.6,-4.15,0.1,4.25,4.5,0.6,-3.85,-4.75,-1.3,3.35,4.95,2,-2.8,-5,-2.6,2.2,4.95,3.2,-1.5,-4.85,-3.7,0.85,4.6,4.15,-0.15,-4.3};\n", - "TSeries d14a = new() {-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0.2,-0.2,0,0,0.59,0.83,0.74,0.5,0.91,1.36,0.93,0.87,0.6,0.38,0.78,0.53,0.42,0.14,0.01,-0.45,-0.71,-0.99,-1,-1.36,-1.22,-1.07,-1.17,-0.56,-0.95,-1.11,-0.16,0.18,-0.28,0.64,-0.5,0.24,0.45,0.67,0.72,1.15,1.52,1.28,1.38,1.03,-0.47,0.96,0.65,0.28,0.3,0.17,-0.07,-0.67,-0.51,-1.33,-0.33,-1.34,-0.78,-1.21,-0.68,-0.43,-0.56,-0.87,-0.93,-0.4,0.52,0.1,1.18,1.18,1.35};\n", - "TSeries d15a = new() {0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,0,0.01,1.3,0.3,-0.48,-1.1,-1.14,-0.03,1.11,0.96,0.63,-0.21,-0.97,-0.73,-0.65,-0.06,0.51,1.08,0.99,0.72,0.12,-0.35,-1.12,-1.21,-1.02,-0.87,0.12,0.13,0.24,1.26,1.44,0.58,0.95,-0.82,-0.68,-0.98,-1.08,-1.17,-0.67,-0.06,0.06,0.6,0.69,-0.41,1.33,1.24,0.98,1.01,0.81,0.45,-0.3,-0.28,-1.22,-0.31,-1.35,-0.77,-1.13,-0.5,-0.13,-0.13,-0.32,-0.29,0.3,1.22,0.75,1.73,1.59,1.58};\n", - "TSeries d16a = new() {175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.1,175.6,175.44,176.27,176.04,176.99,175.49,175.68,174.34,176.4,174.05,174.4,174.2,176.16,175,177.72,174.33,176.96,174.62,174.76,170.9,171.12,171.05,170.01,169.24,172.64,171.96,175.72,174.16,175.81,177.3,178.38,176.75,177.19,175.55,178.49,176.52,178.45,178.04,178.25,177.8,176.97,172.94,174.92,173.98,172.29,171.19,172.54,172.11,175.32,175.63,176.65,173.8,176.04,172.74,175.24,171.84,171.54,172.17,171.85,172.38,170.78,173.49,173.69,171.71,174.38,173.99,174.83};" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "dotnet_interactive": { - "language": "csharp" - }, - "polyglot_notebook": { - "kernelName": "csharp" - } - }, - "outputs": [], - "source": [ - "int period = 10;\n", - "int cut = 26;\n", - "\n", - "SMA_Series d1b = new(d1a, period);\n", - "SMA_Series d2b = new(d2a, period);\n", - "SMA_Series d3b = new(d3a, period);\n", - "SMA_Series d4b = new(d4a, period);\n", - "SMA_Series d5b = new(d5a, period);\n", - "SMA_Series d6b = new(d6a, period);\n", - "SMA_Series d7b = new(d7a, period);\n", - "SMA_Series d8b = new(d8a, period);\n", - "SMA_Series d9b = new(d9a, period);\n", - "SMA_Series d10b = new(d10a, period);\n", - "SMA_Series d11b = new(d11a, period);\n", - "SMA_Series d12b = new(d12a, period);\n", - "SMA_Series d13b = new(d13a, period);\n", - "SMA_Series d14b = new(d14a, period);\n", - "SMA_Series d15b = new(d15a, period);\n", - "SMA_Series d16b = new(d16a, period);\n", - "\n", - "List x = Enumerable.Range(-cut,96).ToList();\n", - "GenericChart.GenericChart ch1a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d1a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch1b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d1b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch2a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d2a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch2b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d2b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch3a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d3a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch3b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d3b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch4a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d4a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch4b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d4b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch5a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d5a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch5b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d5b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch6a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d6a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch6b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d6b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch7a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d7a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch7b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d7b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch8a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d8a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch8b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d8b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch9a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d9a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch9b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d9b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch10a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d10a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch10b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d10b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch11a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d11a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch11b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d11b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch12a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d12a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch12b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d12b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch13a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d13a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch13b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d13b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch14a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d14a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch14b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d14b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch15a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d15a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch15b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d15b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "GenericChart.GenericChart ch16a = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d16a.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 1.0, Color: Color.fromString(\"blue\"));\n", - "GenericChart.GenericChart ch16b = Chart2D.Chart.Line(x.GetRange(cut,96-cut),d16b.v.GetRange(cut,96-cut),false,\"\").WithLineStyle(Width: 2.5, Color: Color.fromString(\"red\"));\n", - "\n", - "var ch1 = Chart.Combine(new []{ch1a,ch1b});\n", - "var ch2 = Chart.Combine(new []{ch2a,ch2b});\n", - "var ch3 = Chart.Combine(new []{ch3a,ch3b});\n", - "var ch4 = Chart.Combine(new []{ch4a,ch4b});\n", - "var ch5 = Chart.Combine(new []{ch5a,ch5b});\n", - "var ch6 = Chart.Combine(new []{ch6a,ch6b});\n", - "var ch7 = Chart.Combine(new []{ch7a,ch7b});\n", - "var ch8 = Chart.Combine(new []{ch8a,ch8b});\n", - "var ch9 = Chart.Combine(new []{ch9a,ch9b});\n", - "var ch10 = Chart.Combine(new []{ch10a,ch10b});\n", - "var ch11 = Chart.Combine(new []{ch11a,ch11b});\n", - "var ch12 = Chart.Combine(new []{ch12a,ch12b});\n", - "var ch13 = Chart.Combine(new []{ch13a,ch13b});\n", - "var ch14 = Chart.Combine(new []{ch14a,ch14b});\n", - "var ch15 = Chart.Combine(new []{ch15a,ch15b});\n", - "var ch16 = Chart.Combine(new []{ch16a,ch16b});\n", - "\n", - "Layout layout = new Layout(); layout.SetValue(\"showlegend\",false);\n", - "var chart1 = new []{ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9,ch10,ch11,ch12,ch13,ch14,ch15,ch16};\n", - "var full = Chart.Grid>(8,2).Invoke(chart1).WithSize(1000,2200).WithMargin(Margin.init(30,20,20,30,7,false)).WithLayout(layout);\n", - "full.SaveSVG(\"SMA_chart\", Width: 1000, Height: 2200);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".NET (C#)", - "language": "C#", - "name": ".net-csharp" - }, - "polyglot_notebook": { - "kernelInfo": { - "defaultKernelName": "csharp", - "items": [ - { - "aliases": [ - "c#", - "C#" - ], - "languageName": "C#", - "name": "csharp" - }, - { - "aliases": [], - "name": ".NET" - }, - { - "aliases": [ - "f#", - "F#" - ], - "languageName": "F#", - "name": "fsharp" - }, - { - "aliases": [], - "languageName": "HTML", - "name": "html" - }, - { - "aliases": [], - "languageName": "KQL", - "name": "kql" - }, - { - "aliases": [], - "languageName": "Mermaid", - "name": "mermaid" - }, - { - "aliases": [ - "powershell" - ], - "languageName": "PowerShell", - "name": "pwsh" - }, - { - "aliases": [], - "languageName": "SQL", - "name": "sql" - }, - { - "aliases": [], - "name": "value" - }, - { - "aliases": [ - "frontend" - ], - "name": "vscode" - }, - { - "aliases": [ - "js" - ], - "languageName": "JavaScript", - "name": "javascript" - }, - { - "aliases": [], - "name": "webview" - } - ] - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/docs/img/SMMA_chart.svg b/docs/img/SMMA_chart.svg new file mode 100644 index 00000000..e856b1f3 --- /dev/null +++ b/docs/img/SMMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/T3_chart.svg b/docs/img/T3_chart.svg new file mode 100644 index 00000000..c1d87c5f --- /dev/null +++ b/docs/img/T3_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/TEMA_chart.svg b/docs/img/TEMA_chart.svg new file mode 100644 index 00000000..4351664f --- /dev/null +++ b/docs/img/TEMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1010204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.510204060−1001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/TRIMA_chart.svg b/docs/img/TRIMA_chart.svg new file mode 100644 index 00000000..ad79cb56 --- /dev/null +++ b/docs/img/TRIMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/WMA_chart.svg b/docs/img/WMA_chart.svg new file mode 100644 index 00000000..15e010d0 --- /dev/null +++ b/docs/img/WMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/ZLEMA_chart.svg b/docs/img/ZLEMA_chart.svg new file mode 100644 index 00000000..fe9ceab2 --- /dev/null +++ b/docs/img/ZLEMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/indicators.md b/docs/indicators.md index 9da29d03..bec75679 100644 --- a/docs/indicators.md +++ b/docs/indicators.md @@ -52,7 +52,7 @@ |||||| |AFIRMA - Autoregressive Finite Impulse Response Moving Average||||| |ALMA - Arnaud Legoux Moving Average|`ALMA_Series`||✔️GetAlma|alma| -|DEMA - Double EMA Average|`DEMA_Series`|❌DEMA|✔️GetDema|✔️dema|❌dema| +|DEMA - Double EMA Average|`DEMA_Series`|✔️DEMA|✔️GetDema|✔️dema|❌dema| |DWMA - Double WMA Average|`DWMA_Series`||||| |⭐EMA - Exponential Moving Average|`EMA_Series`|✔️EMA|✔️GetEma|✔️ema|✔️ema| |EPMA - Endpoint Moving Average|||GetEpma|| @@ -80,7 +80,7 @@ |SSF - Ehler's Super Smoother Filter||||ssf| |SUPERTREND - Supertrend||||supertrend| |SWMA - Symmetric Weighted Moving Average||||swma| -|T3 - Tillson T3 Moving Average|`T3_Series`|❌T3|❌GetT3|✔️t3| +|T3 - Tillson T3 Moving Average|`T3_Series`|✔️T3|✔️GetT3|✔️t3| |TEMA - Triple EMA Average|`TEMA_Series`|✔️TEMA|✔️GetTema|✔️tema|❌tema| |⭐TRIMA - Triangular Moving Average|`TRIMA_Series`|✔️TRIMA||✔️trima|✔️trima| |TSF - Time Series Forecast||TSF||| @@ -151,7 +151,7 @@ |SMI - Stochastic Momentum Index||||| |STC - Schaff Trend Cycle||||| |STOCH - Stochastic Oscillator||STOCH|GetStoch|| -|TRIX - 1-day ROC of TEMA|`TRIX_Series`|❌TRIX|❌GetTrix|✔️trix|❌trix| +|TRIX - 1-day ROC of TEMA|`TRIX_Series`|✔️TRIX|✔️GetTrix|✔️trix|❌trix| |TSI - True Strength Index||||| |UO - Ultimate Oscillator||ULTOSC|GetUltimate||ultosc| |WILLR - Larry Williams' %R||WILLR|GetWilliamsR||willr| From 83e5d89cbbeaccd10bce14bc7d65a75a182a48ab Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Tue, 27 Dec 2022 12:06:54 -0800 Subject: [PATCH 2/6] HWMA --- .github/workflows/main_automation.yml | 8 ++++ Source/Trends/HWMA_Series.cs | 57 +++++++++++++++++++++++++++ Source/Trends/JMA_Series.cs | 9 ++--- Tests/Series/Update.cs | 13 +++++- Tests/Validations/Trends/Pandas_TA.cs | 13 +++++- docs/HWMA.md | 4 ++ docs/MAMA.md | 4 ++ docs/_sidebar.md | 9 +++-- docs/img/HWMA_chart.svg | 1 + docs/img/MAMA_chart.svg | 2 +- docs/img/T3_chart.svg | 2 +- docs/indicators.md | 2 +- 12 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 Source/Trends/HWMA_Series.cs create mode 100644 docs/HWMA.md create mode 100644 docs/MAMA.md create mode 100644 docs/img/HWMA_chart.svg diff --git a/.github/workflows/main_automation.yml b/.github/workflows/main_automation.yml index e84ae92e..53c6ac2a 100644 --- a/.github/workflows/main_automation.yml +++ b/.github/workflows/main_automation.yml @@ -57,10 +57,13 @@ jobs: run: dotnet build ./Quantower/Quantower.csproj --verbosity normal --configuration Release --nologo - name: dotnet Test + if: ${{ github.ref == 'refs/heads/dev' }} run: dotnet test ./Tests/Tests.csproj --verbosity normal --configuration Release --nologo - name: DotCover Test XML + if: ${{ github.ref == 'refs/heads/dev' }} run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=DetailedXML --dcoutput=./coveragereport.xml - name: DotCover Test HTML + if: ${{ github.ref == 'refs/heads/dev' }} run: dotnet dotcover test ./Tests/Tests.csproj --verbosity normal --framework net7.0 --dcReportType=HTML --dcoutput=./coveragereport.html # - name: dotnet-coverage # run: dotnet-coverage collect 'dotnet test' -f xml -o './coverage.xml' @@ -72,15 +75,18 @@ jobs: run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" - name: CodeCov run + if: ${{ github.ref == 'refs/heads/dev' }} run: codecov -f ./coveragereport.xml -v -t ${{ secrets.CODECOV_TOKEN }} - name: Codacy coverage reporter + if: ${{ github.ref == 'refs/heads/dev' }} uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} coverage-reports: ./coveragereport.xml - name: Release + if: ${{ github.ref == 'refs/heads/main' }} uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" @@ -90,6 +96,7 @@ jobs: files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.dll - name: Authenticate to Github packages source + if: ${{ github.ref == 'refs/heads/main' }} run: dotnet nuget add source --username mihakralj --password ${{ secrets.GITHUB_TOKEN }} @@ -97,6 +104,7 @@ jobs: --name github "https://nuget.pkg.github.com/mihakralj/index.json" - name: Push package to github + if: ${{ github.ref == 'refs/heads/main' }} run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg' --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/mihakralj/index.json diff --git a/Source/Trends/HWMA_Series.cs b/Source/Trends/HWMA_Series.cs new file mode 100644 index 00000000..50754285 --- /dev/null +++ b/Source/Trends/HWMA_Series.cs @@ -0,0 +1,57 @@ +namespace QuanTAlib; +using System; + +/* +HWMA: Holt-Winter Moving Average + Indicator HWMA (Holt-Winter Moving Average) is a three-parameter moving + average by the Holt-Winter method; Holt-Winters Exponential Smoothing is + used for forecasting time series data that exhibits both a trend and a + seasonal variation. + + +Sources: + https://timeseriesreasoning.com/contents/holt-winters-exponential-smoothing/ + https://www.mql5.com/en/code/20856 + +nA - smoothed series (from 0 to 1) +nB - assess the trend (from 0 to 1) +nC - assess seasonality (from 0 to 1) + +F[i] = (1-nA) * (F[i-1] + V[i-1] + 0.5 * A[i-1]) + nA * Price[i] +V[i] = (1-nB) * (V[i-1] + A[i-1]) + nB * (F[i] - F[i-1]) +A[i] = (1-nC) * A[i-1] + nC * (V[i] - V[i-1]) +HWMA[i] = F[i] + V[i] + 0.5 * A[i] + + */ + +public class HWMA_Series : Single_TSeries_Indicator { + double _nA, _nB, _nC; + double _pF, _pV, _pA; + double _ppF, _ppV, _ppA; + + public HWMA_Series(TSeries source, double nA = 0.2, double nB = 0.1, double nC = 0.1, bool useNaN = false) : base(source, 0, useNaN) { + + _nA = nA; + _nB = nB; + _nC = nC; + if (this._data.Count > 0) { base.Add(this._data); } + } + public override void Add((DateTime t, double v) TValue, bool update) { + double _F, _V, _A; + if (this.Count == 0) { _pF = TValue.v; _pA = _pV = 0; } + + if (update) { _pF = _ppF; _pV = _ppV; _pA = _ppA; } + else { _ppF = _pF; _ppV = _pV; _ppA = _pA; } + + _F = (1 - _nA) * (_pF + _pV + 0.5 * _pA) + _nA * TValue.v; + _V = (1 - _nB) * (_pV + _pA) + _nB * (_F - _pF); + _A = (1 - _nC) * _pA + _nC * (_V - _pV); + + double _hwma = _F + _V + 0.5 * _A; + _pF = _F; + _pV = _V; + _pA = _A; + + base.Add((TValue.t, _hwma), update, _NaN); + } +} diff --git a/Source/Trends/JMA_Series.cs b/Source/Trends/JMA_Series.cs index af37b43d..0a8b201d 100644 --- a/Source/Trends/JMA_Series.cs +++ b/Source/Trends/JMA_Series.cs @@ -91,9 +91,8 @@ public class JMA_Series : Single_TSeries_Indicator { /// from avolty to rolty double rvolty = (avolty != 0) ? volty / avolty : 0; - double len1 = (Math.Log(Math.Sqrt(0.5 * (_p - 1))) / Math.Log(2.0)) + 2; - if (len1 < 0) - len1 = 0; + double len1 = (Math.Log(Math.Sqrt(2.0 * _p)) / Math.Log(2.0)) + 2; + if (len1 < 0) len1 = 0; double pow1 = Math.Max(len1 - 2.0, 0.5); if (rvolty > Math.Pow(len1, 1.0 / pow1)) rvolty = Math.Pow(len1, 1.0 / pow1); @@ -102,7 +101,7 @@ public class JMA_Series : Single_TSeries_Indicator { //// from rvolty to second smoothing double pow2 = Math.Pow(rvolty, pow1); - double len2 = Math.Sqrt(0.5 * (_p - 1)) * len1; + double len2 = Math.Sqrt(0.5 * (_p - 2)) * len1; Kv = Math.Pow(len2 / (len2 + 2), Math.Sqrt(pow2)); double beta = 0.45 * (_p - 1) / (0.45 * (_p - 1) + 2); double alpha = Math.Pow(beta * 1.1, pow2); @@ -120,6 +119,6 @@ public class JMA_Series : Single_TSeries_Indicator { double jma = prev_jma + det1; prev_jma = jma; - base.Add((TValue.t, ma1), update, _NaN); + base.Add((TValue.t, jma), update, _NaN); } } \ No newline at end of file diff --git a/Tests/Series/Update.cs b/Tests/Series/Update.cs index 80335697..e477da9f 100644 --- a/Tests/Series/Update.cs +++ b/Tests/Series/Update.cs @@ -175,7 +175,18 @@ public class Update { Assert.Equal(lastLen, QL.Count); // same size Assert.Equal(lastCalc, QL.Last()); // same data } - [Fact] public void JMA() { + [Fact] + public void HWMA() { + HWMA_Series QL = new(source: bars.Close); + var lastData = bars.Close.Last(); + var lastCalc = QL.Last(); + int lastLen = QL.Count; + QL.Add((DateTime.Today, 0), update: true); + QL.Add(lastData, update: true); + Assert.Equal(lastLen, QL.Count); // same size + Assert.Equal(lastCalc, QL.Last()); // same data + } + [Fact] public void JMA() { JMA_Series QL = new(source: bars.Close, period: period); var lastData = bars.Close.Last(); var lastCalc = QL.Last(); diff --git a/Tests/Validations/Trends/Pandas_TA.cs b/Tests/Validations/Trends/Pandas_TA.cs index 5549a5c2..7da08900 100644 --- a/Tests/Validations/Trends/Pandas_TA.cs +++ b/Tests/Validations/Trends/Pandas_TA.cs @@ -165,7 +165,18 @@ public class PandasTA : IDisposable Assert.InRange(PanTA_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } - } + } + [Fact] void HWMA() { + HWMA_Series QL = new(bars.Close, useNaN: false); + var pta = df.ta.hwma(close: df.close); + for (int i = QL.Length; i > QL.Length-sample; i--) + { + double QL_item = QL[i - 1].v; + double PanTA_item = (double)pta[i - 1]; + Assert.InRange(PanTA_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); + } + + } [Fact] void KAMA() { KAMA_Series QL = new(bars.Close, period); var pta = df.ta.kama(close: df.close, length: period); diff --git a/docs/HWMA.md b/docs/HWMA.md new file mode 100644 index 00000000..6102933e --- /dev/null +++ b/docs/HWMA.md @@ -0,0 +1,4 @@ +# HWMA: Holt-Winter Moving Average +nA = 0.5; nB = 0.3; nC = 0.01; + +![Alt text](./img/HWMA_chart.svg) \ No newline at end of file diff --git a/docs/MAMA.md b/docs/MAMA.md new file mode 100644 index 00000000..19dacbb0 --- /dev/null +++ b/docs/MAMA.md @@ -0,0 +1,4 @@ +# MAMA: MESA Adaptive Moving Average +period = 10 + +![Alt text](./img/MAMA_chart.svg) \ No newline at end of file diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 52a8a6dd..f59cf77c 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -3,19 +3,20 @@ * [List of all Indicators](indicators.md "Indicators coverage") * [SMA - Simple Moving Average](SMA.md) - * [RMA - WildeR Moving Average](RMA.md) * [EMA - Exponential Moving Average](EMA.md) * [WMA - Weighted Moving Average](WMA.md) + * [T3 - Tillson T3 Exponential MA](T3.md) * [SMMA - Smoothed Moving Average](SMMA.md) - * [DWMA - Double Weighted Moving Average](DWMA.md) * [TRIMA - Triangular Moving Average](TRIMA.md) + * [DWMA - Double Weighted Moving Average](DWMA.md) * [DEMA - Double Exponential MA](DEMA.md) * [TEMA - Triple Exponential MA](TEMA.md) - * [T3 - Tillson T3 Exponential MA](T3.md) + * [ALMA - Arnaud Legoux Moving Average](ALMA.md) * [HMA - Hull Moving Average](HMA.md) * [HEMA - Hull/Exponential Moving Average](HEMA.md) + * [HWMA - Holt-Winter Moving Average](HWMA.md) + * [MAMA - MESA Adaptive Moving Average](MAMA.md) * [KAMA - Kaufman Adaptive Moving Average](KAMA.md) - * [ALMA - Arnaud Legoux Moving Average](ALMA.md) * [ZLEMA - Zero-Lag Exponential MA](ZLEMA.md) * [JMA - Jurik Moving Average](JMA.md) diff --git a/docs/img/HWMA_chart.svg b/docs/img/HWMA_chart.svg new file mode 100644 index 00000000..660fa53f --- /dev/null +++ b/docs/img/HWMA_chart.svg @@ -0,0 +1 @@ +020406000.20.40.60.81020406000.510204060−100102030020406001020300204060−1−0.500.510204060−1010204060−1010204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.511.50204060−100102030400204060−1010204060−10120204060170175 \ No newline at end of file diff --git a/docs/img/MAMA_chart.svg b/docs/img/MAMA_chart.svg index 3a17f18e..fd2cef35 100644 --- a/docs/img/MAMA_chart.svg +++ b/docs/img/MAMA_chart.svg @@ -1 +1 @@ -020406000.5×10​621×10​62020406002×10​594×10​596×10​598×10​590204060−3×10​45−2×10​45−1×10​450020406001×10​402×10​400204060−1.5×10​19−1×10​19−0.5×10​1900204060−5×10​3805×10​380204060−5×10​2205×10​22020406001×10​482×10​48020406000.5×10​331×10​331.5×10​33020406001×10​692×10​693×10​694×10​690204060−1×10​37−0.5×10​3700204060−1×10​34−0.5×10​3400204060−3×10​33−2×10​33−1×10​3300204060−1×10​28−0.5×10​280020406002×10​244×10​246×10​24020406002×10​224×10​226×10​22 \ No newline at end of file +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/T3_chart.svg b/docs/img/T3_chart.svg index c1d87c5f..906a89ab 100644 --- a/docs/img/T3_chart.svg +++ b/docs/img/T3_chart.svg @@ -1 +1 @@ -020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file +020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/indicators.md b/docs/indicators.md index bec75679..514e1c35 100644 --- a/docs/indicators.md +++ b/docs/indicators.md @@ -62,7 +62,7 @@ |HEMA - Hull/EMA Average|`HEMA_Series`|||| |Hilbert Transform Instantaneous Trendline||HT_TRENDLINE|GetHtTrendline|| |⭐HMA - Hull Moving Average|`HMA_Series`||✔️GetHma|✔️hma|✔️hma| -|HWMA - Holt-Winter Moving Average||||hwma| +|HWMA - Holt-Winter Moving Average|`HWMA_Series`|||✔️hwma| |JMA - Jurik Moving Average|`JMA_Series`|||jma|| |KAMA - Kaufman's Adaptive Moving Average|`KAMA_Series`|✔️KAMA|✔️GetKama|✔️kama|✔️kama| |KDJ - KDJ Indicator (trend reversal)||||kdj| From 5d72f9d3aecd6b3a3a699be0bea14979c3a04158 Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Tue, 3 Jan 2023 17:55:41 -0800 Subject: [PATCH 3/6] Fixed ATR and ATRP, improved SMA --- Source/QuanTAlib.csproj | 4 +- Source/Trends/SMA_Series.cs | 26 ++++++++- Source/Volatility/ATRP_Series.cs | 76 +++++++++++---------------- Source/Volatility/ATR_Series.cs | 71 ++++++++++--------------- Tests/Validations/Trends/Pandas_TA.cs | 4 +- Tests/Validations/Trends/Skender.cs | 71 +++++++++++++------------ Tests/Validations/Trends/TA_LIB.cs | 4 +- Tests/Validations/Trends/Tulip.cs | 8 ++- 8 files changed, 135 insertions(+), 129 deletions(-) diff --git a/Source/QuanTAlib.csproj b/Source/QuanTAlib.csproj index 3aa1b3b8..87a32a2e 100644 --- a/Source/QuanTAlib.csproj +++ b/Source/QuanTAlib.csproj @@ -2,9 +2,9 @@ QuanTAlib - 0.1.24 + 0.1.25 Library of Technical Indicators for .NET - Quantitative Technical Analysis library for both real-time (streaming) and historical data analysis + Quantitative Technical Analysis library for real-time (streaming) data analysis git https://github.com/mihakralj/QuanTAlib true diff --git a/Source/Trends/SMA_Series.cs b/Source/Trends/SMA_Series.cs index 48e45ec4..a263532c 100644 --- a/Source/Trends/SMA_Series.cs +++ b/Source/Trends/SMA_Series.cs @@ -16,6 +16,30 @@ Remark:
*/ +public class SMA_Series : Single_TSeries_Indicator { + private double _sum, _oldsum; + private int _len, _oldlen; + + public SMA_Series(TSeries source, int period = 0, bool useNaN = false) : base(source, period, false) { + Reset(); + if (this._data.Count > 0) { base.Add(this._data); } + } + + public override void Add((DateTime t, double v) TValue, bool update) { + if (update) { _sum = _oldsum; } + else { _oldsum = _sum; _len++; } + _sum += TValue.v; + if (_period != 0 && _len > _period) + _sum -= (_data[base.Count - _period - (update ? 1 : 0)].v); + double _div = (_period == 0) ? _len : Math.Min(_len, _period); + base.Add((TValue.t, _sum / _div), update, _NaN); + } + public void Reset() { + _sum = _oldsum = 0; + _len = _oldlen = 0; + } +} +/* public class SMA_Series : Single_TSeries_Indicator { private readonly System.Collections.Generic.List _buffer = new(); @@ -59,4 +83,4 @@ public class SMA_Series : Single_TSeries_Indicator base.Add((TValue.t, _sma), update, _NaN); } -} \ No newline at end of file +}*/ diff --git a/Source/Volatility/ATRP_Series.cs b/Source/Volatility/ATRP_Series.cs index 884e92a2..5bfedfc0 100644 --- a/Source/Volatility/ATRP_Series.cs +++ b/Source/Volatility/ATRP_Series.cs @@ -11,53 +11,39 @@ Sources: */ -public class ATRP_Series : Single_TBars_Indicator -{ - private readonly System.Collections.Generic.List _buffer = new(); - private readonly double _k, _k1m; - private double _lastema, _lastlastema, _lastcm1; - private double _cm1 = double.NaN; +public class ATRP_Series : Single_TBars_Indicator { + private readonly System.Collections.Generic.List _buffer = new(); + private readonly double _k; + private double _lastatr, _lastlastatr, _cm1, _lastcm1, _sum, _oldsum; + private readonly int _period; - public ATRP_Series(TBars source, int period, bool useNaN = false) : base(source, period, useNaN) - { - this._k = 1.0 / (double)(this._p); - this._k1m = 1.0 - this._k; - this._lastema = this._lastlastema = double.NaN; - if (_bars.Count > 0) { base.Add(_bars); } - } + public ATRP_Series(TBars source, int period, bool useNaN = false) : base(source, period, useNaN) { + _period = period; + _k = 1.0 / (double)(_p); + _lastatr = _lastlastatr = _cm1 = _lastcm1 = _sum = _oldsum = 0; + if (this._bars.Count > 0) { base.Add(this._bars); } + } - public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update) - { - if (update) { - this._lastema = this._lastlastema; - this._cm1 = this._lastcm1; - } + public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update) { + if (update) { _lastatr = _lastlastatr; _cm1 = _lastcm1; _sum = _oldsum; } + else { _lastlastatr = _lastatr; _lastcm1 = _cm1; _oldsum = _sum; } - if (_cm1 is double.NaN) { _cm1 = TBar.c; } - double d1 = Math.Abs(TBar.h - TBar.l); - double d2 = Math.Abs(_cm1 - TBar.h); - double d3 = Math.Abs(_cm1 - TBar.l); - (DateTime t, double v)d = (TBar.t, Math.Max(d1,Math.Max(d2,d3))); //TR value for RMA below - _lastcm1 = _cm1; - _cm1 = TBar.c; + if (this.Count == 0) + _cm1 = TBar.c; + double d1 = Math.Abs(TBar.h - TBar.l); + double d2 = Math.Abs(_cm1 - TBar.h); + double d3 = Math.Abs(_cm1 - TBar.l); + (DateTime t, double v) d = (TBar.t, Math.Max(d1, Math.Max(d2, d3))); + _cm1 = TBar.c; - double _ema = 0; - if (this.Count < this._p) - { - if (update) { _buffer[_buffer.Count - 1] = d.v; } - else { _buffer.Add(d.v); } - if (_buffer.Count > this._p) { _buffer.RemoveAt(0); } - for (int i = 0; i < _buffer.Count; i++) { _ema += _buffer[i]; } - _ema /= this._buffer.Count; - } - else { _ema = (d.v * _k) + (_lastema * _k1m); } + double _atr = 0; + if (this.Count == 0) { _atr = d.v; } + else if (this.Count < _p + 1) { _sum += d.v; _atr = _sum / (this.Count); } + else { _atr = _k * (d.v - _lastatr) + _lastatr; } + _lastatr = _atr; - this._lastlastema = this._lastema; - this._lastema = _ema; - - double _atrp = 100 * (_ema / TBar.c); - - var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _atrp); - base.Add(ret, update); - } -} \ No newline at end of file + double _atrp = 100 * (_atr / TBar.c); + var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _atrp); + base.Add(ret, update); + } +} diff --git a/Source/Volatility/ATR_Series.cs b/Source/Volatility/ATR_Series.cs index 41e288c7..5e4d4bab 100644 --- a/Source/Volatility/ATR_Series.cs +++ b/Source/Volatility/ATR_Series.cs @@ -13,51 +13,38 @@ Sources: */ -public class ATR_Series : Single_TBars_Indicator -{ - private readonly System.Collections.Generic.List _buffer = new(); - private readonly double _k, _k1m; - private double _lastema, _lastlastema, _lastcm1; - private double _cm1; +public class ATR_Series : Single_TBars_Indicator { + private readonly System.Collections.Generic.List _buffer = new(); + private readonly double _k; + private double _lastatr, _lastlastatr, _cm1, _lastcm1, _sum, _oldsum; + private readonly int _period; - public ATR_Series(TBars source, int period, bool useNaN = false) : base(source, period, useNaN) - { - this._k = 1.0 / (double)(this._p); - this._k1m = 1.0 - this._k; - this._lastema = this._lastlastema = double.NaN; - if (this._bars.Count > 0) { base.Add(this._bars); } - } + public ATR_Series(TBars source, int period, bool useNaN = false) : base(source, period, useNaN) { + _period = period; + _k = 1.0 / (double)(_p); + _lastatr = _lastlastatr = _cm1 = _lastcm1 = _sum = _oldsum = 0; + if (this._bars.Count > 0) { base.Add(this._bars); } + } - public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update) - { - if (update) { - this._lastema = this._lastlastema; - this._cm1 = this._lastcm1; - } + public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update) { + if (update) { _lastatr = _lastlastatr; _cm1 = _lastcm1; _sum = _oldsum; } + else { _lastlastatr = _lastatr; _lastcm1 = _cm1; _oldsum = _sum; } - if (this.Count == 0) { this._cm1 = TBar.c; } - double d1 = Math.Abs(TBar.h - TBar.l); - double d2 = Math.Abs(_cm1 - TBar.h); - double d3 = Math.Abs(_cm1 - TBar.l); - (DateTime t, double v)d = (TBar.t, Math.Max(d1,Math.Max(d2,d3))); - _lastcm1 = _cm1; - _cm1 = TBar.c; + if (this.Count == 0) + _cm1 = TBar.c; + double d1 = Math.Abs(TBar.h - TBar.l); + double d2 = Math.Abs(_cm1 - TBar.h); + double d3 = Math.Abs(_cm1 - TBar.l); + (DateTime t, double v) d = (TBar.t, Math.Max(d1, Math.Max(d2, d3))); + _cm1 = TBar.c; - double _ema = 0; - if (this.Count < this._p) - { - if (update) { _buffer[_buffer.Count - 1] = d.v; } - else { _buffer.Add(d.v); } - if (_buffer.Count > this._p) { _buffer.RemoveAt(0); } - for (int i = 0; i < _buffer.Count; i++) { _ema += _buffer[i]; } - _ema /= this._buffer.Count; - } - else { _ema = (d.v * _k) + (_lastema * _k1m); } + double _atr = 0; + if (this.Count == 0) { _atr = d.v; } + else if (this.Count < _p + 1) { _sum += d.v; _atr = _sum / (this.Count); } + else { _atr = _k * (d.v - _lastatr) + _lastatr; } + _lastatr = _atr; - this._lastlastema = this._lastema; - this._lastema = _ema; - - var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _ema); - base.Add(ret, update); - } + var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _atr); + base.Add(ret, update); + } } \ No newline at end of file diff --git a/Tests/Validations/Trends/Pandas_TA.cs b/Tests/Validations/Trends/Pandas_TA.cs index 7da08900..23cfc6f9 100644 --- a/Tests/Validations/Trends/Pandas_TA.cs +++ b/Tests/Validations/Trends/Pandas_TA.cs @@ -1,3 +1,4 @@ +/* using Xunit; using System; using QuanTAlib; @@ -402,4 +403,5 @@ public class PandasTA : IDisposable } } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/Tests/Validations/Trends/Skender.cs b/Tests/Validations/Trends/Skender.cs index 757acb07..530af8ea 100644 --- a/Tests/Validations/Trends/Skender.cs +++ b/Tests/Validations/Trends/Skender.cs @@ -16,7 +16,7 @@ public class Skender { bars = new(Bars: 10000, Volatility: 0.5, Drift: 0.0, Precision: 2); period = rnd.Next(30) + 5; - digits = 5; //minimizing rounding errors in type conversions + digits = 6; //minimizing rounding errors in type conversions skip = period+2; quotes = bars.Select(q => new Quote @@ -206,20 +206,21 @@ public class Skender { HMA_Series QL = new(bars.Close, period, useNaN: false); var SK = quotes.GetHma(period).Select(i => i.Hma.Null2NaN()!); - for (int i = QL.Length; i > skip; i--) + for (int i = QL.Length; i > skip*2; i--) { double QL_item = QL[i - 1].v; double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits)); } } + [Fact] public void KAMA() { // TODO: check precision of KAMA() KAMA_Series QL = new(bars.Close, period, useNaN: false); var SK = quotes.GetKama(period).Select(i => i.Kama.Null2NaN()!); - for (int i = QL.Length; i > 250; i--) + for (int i = QL.Length; i > skip+2; i--) { double QL_item = QL[i - 1].v; double SK_item = SK.ElementAt(i - 1); @@ -269,8 +270,8 @@ public class Skender var SK = quotes.GetSmaAnalysis(period).Select(i => i.Mad.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -281,11 +282,11 @@ public class Skender var SK = quotes.GetMama(fastLimit: 0.5, slowLimit: 0.05); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1).Mama.Null2NaN()!, digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1).Mama.Null2NaN()!; Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); - QL_item = Math.Round(QL.Fama[i - 1].v, digits: digits); - SK_item = Math.Round(SK.ElementAt(i - 1).Fama.Null2NaN()!, digits: digits); + QL_item = QL.Fama[i - 1].v; + SK_item = SK.ElementAt(i - 1).Fama.Null2NaN()!; Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -296,8 +297,8 @@ public class Skender var SK = quotes.GetSmaAnalysis(period).Select(i => i.Mape.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -308,8 +309,8 @@ public class Skender var SK = quotes.GetSmaAnalysis(period).Select(i => i.Mse.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -319,9 +320,9 @@ public class Skender OBV_Series QL = new(bars, period, false); var SK = quotes.GetObv(period).Select(i => i.Obv!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL.Last().v, digits: digits); + double QL_item = QL.Last().v; // adding volume[0] to OBV to pass the test and keep compatibility with TA-LIB - double SK_item = Math.Round(SK.Last()! + (double)quotes.First().Volume!, digits: digits); + double SK_item = SK.Last()! + (double)quotes.First().Volume!; Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -368,8 +369,8 @@ public class Skender var SK = quotes.GetRsi(period).Select(i => i.Rsi.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -380,8 +381,8 @@ public class Skender var SK = quotes.GetStdDev(period).Select(i => i.StdDev.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -392,8 +393,8 @@ public class Skender var SK = quotes.GetSma(period).Select(i => i.Sma.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -404,8 +405,8 @@ public class Skender var SK = quotes.GetSmma(period).Select(i => i.Smma.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -416,8 +417,8 @@ public class Skender var SK = quotes.GetT3(lookbackPeriods: period, volumeFactor: 0.7).Select(i => i.T3.Null2NaN()!); for (int i = QL.Length; i > period*15; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -426,8 +427,8 @@ public class Skender TRIX_Series QL = new(bars.Close, period, false); var SK = quotes.GetTrix(period).Select(i => i.Trix.Null2NaN()!); for (int i = QL.Length; i > period*12; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits)); } } @@ -438,8 +439,8 @@ public class Skender var SK = quotes.GetTema(period).Select(i => i.Tema.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -450,8 +451,8 @@ public class Skender var SK = quotes.GetTr().Select(i => i.Tr.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -462,8 +463,8 @@ public class Skender var SK = quotes.GetWma(period).Select(i => i.Wma.Null2NaN()!); for (int i = QL.Length; i > skip*2; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } @@ -474,8 +475,8 @@ public class Skender var SK = quotes.GetStdDev(period).Select(i => i.ZScore.Null2NaN()!); for (int i = QL.Length; i > skip; i--) { - double QL_item = Math.Round(QL[i - 1].v, digits: digits); - double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits); + double QL_item = QL[i - 1].v; + double SK_item = SK.ElementAt(i - 1); Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits)); } } diff --git a/Tests/Validations/Trends/TA_LIB.cs b/Tests/Validations/Trends/TA_LIB.cs index 0f34a472..1b372f77 100644 --- a/Tests/Validations/Trends/TA_LIB.cs +++ b/Tests/Validations/Trends/TA_LIB.cs @@ -74,7 +74,7 @@ public class Ta_Lib { ATR_Series QL = new(bars, period, false); Core.Atr(inhigh, inlow, inclose, 0, bars.Count - 1, TALIB, out int outBegIdx, out _, period); - for (int i = QL.Length - 1; i > skip * 15; i--) + for (int i = QL.Length - 1; i > skip; i--) { double QL_item = Math.Round(QL[i].v, digits: digits); double TA_item = Math.Round(TALIB[i - outBegIdx], digits: digits); @@ -114,6 +114,7 @@ public class Ta_Lib Assert.InRange(TA_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } + [Fact] public void CMO() { CMO_Series QL = new(bars.Close, period, false); @@ -124,6 +125,7 @@ public class Ta_Lib Assert.InRange(TA_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } + [Fact] public void CORR() { diff --git a/Tests/Validations/Trends/Tulip.cs b/Tests/Validations/Trends/Tulip.cs index 13a33ee0..e17583a5 100644 --- a/Tests/Validations/Trends/Tulip.cs +++ b/Tests/Validations/Trends/Tulip.cs @@ -20,8 +20,8 @@ public class Tulip_Test { bars = new(Bars: 5000, Volatility: 0.8, Drift: 0.0, Precision: 3); period = rnd.Next(28) + 3; - skip = period+1; - digits = 10; + skip = period+5; + digits = 8; outdata = new double[bars.Count]; inopen = bars.Open.v.ToArray(); @@ -124,6 +124,7 @@ public class Tulip_Test Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } + [Fact] public void CMO() { double[][] arrin = { inclose }; @@ -214,6 +215,7 @@ public class Tulip_Test Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } + [Fact] public void HMA() { double[][] arrin = { inclose }; @@ -226,6 +228,7 @@ public class Tulip_Test Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } + [Fact] public void KAMA() { double[][] arrin = { inclose }; @@ -238,6 +241,7 @@ public class Tulip_Test Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } + [Fact] public void LINREG() { double[][] arrin = { inclose }; From 0986f2035d3be46c6c6766553d74489e3f9d27f9 Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Mon, 26 Dec 2022 19:03:54 -0800 Subject: [PATCH 4/6] Documentation --- docs/_sidebar.md | 9 ++++----- docs/img/JMA_chart.svg | 2 +- docs/img/MAMA_chart.svg | 2 +- docs/img/T3_chart.svg | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index f59cf77c..52a8a6dd 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -3,20 +3,19 @@ * [List of all Indicators](indicators.md "Indicators coverage") * [SMA - Simple Moving Average](SMA.md) + * [RMA - WildeR Moving Average](RMA.md) * [EMA - Exponential Moving Average](EMA.md) * [WMA - Weighted Moving Average](WMA.md) - * [T3 - Tillson T3 Exponential MA](T3.md) * [SMMA - Smoothed Moving Average](SMMA.md) - * [TRIMA - Triangular Moving Average](TRIMA.md) * [DWMA - Double Weighted Moving Average](DWMA.md) + * [TRIMA - Triangular Moving Average](TRIMA.md) * [DEMA - Double Exponential MA](DEMA.md) * [TEMA - Triple Exponential MA](TEMA.md) - * [ALMA - Arnaud Legoux Moving Average](ALMA.md) + * [T3 - Tillson T3 Exponential MA](T3.md) * [HMA - Hull Moving Average](HMA.md) * [HEMA - Hull/Exponential Moving Average](HEMA.md) - * [HWMA - Holt-Winter Moving Average](HWMA.md) - * [MAMA - MESA Adaptive Moving Average](MAMA.md) * [KAMA - Kaufman Adaptive Moving Average](KAMA.md) + * [ALMA - Arnaud Legoux Moving Average](ALMA.md) * [ZLEMA - Zero-Lag Exponential MA](ZLEMA.md) * [JMA - Jurik Moving Average](JMA.md) diff --git a/docs/img/JMA_chart.svg b/docs/img/JMA_chart.svg index 4be3d13e..4443f498 100644 --- a/docs/img/JMA_chart.svg +++ b/docs/img/JMA_chart.svg @@ -1 +1 @@ -020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/MAMA_chart.svg b/docs/img/MAMA_chart.svg index fd2cef35..3a17f18e 100644 --- a/docs/img/MAMA_chart.svg +++ b/docs/img/MAMA_chart.svg @@ -1 +1 @@ -020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file +020406000.5×10​621×10​62020406002×10​594×10​596×10​598×10​590204060−3×10​45−2×10​45−1×10​450020406001×10​402×10​400204060−1.5×10​19−1×10​19−0.5×10​1900204060−5×10​3805×10​380204060−5×10​2205×10​22020406001×10​482×10​48020406000.5×10​331×10​331.5×10​33020406001×10​692×10​693×10​694×10​690204060−1×10​37−0.5×10​3700204060−1×10​34−0.5×10​3400204060−3×10​33−2×10​33−1×10​3300204060−1×10​28−0.5×10​280020406002×10​244×10​246×10​24020406002×10​224×10​226×10​22 \ No newline at end of file diff --git a/docs/img/T3_chart.svg b/docs/img/T3_chart.svg index 906a89ab..c1d87c5f 100644 --- a/docs/img/T3_chart.svg +++ b/docs/img/T3_chart.svg @@ -1 +1 @@ -020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file +020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file From 766edad4d3a911a6d90521edeeb9577808568162 Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Mon, 26 Dec 2022 19:03:54 -0800 Subject: [PATCH 5/6] Documentation --- docs/img/JMA_chart.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/img/JMA_chart.svg b/docs/img/JMA_chart.svg index 4443f498..4be3d13e 100644 --- a/docs/img/JMA_chart.svg +++ b/docs/img/JMA_chart.svg @@ -1 +1 @@ -020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file From 5950dfa655ec31d8bf9618d21d6e5de5a1210ad4 Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Tue, 27 Dec 2022 12:06:54 -0800 Subject: [PATCH 6/6] HWMA --- docs/_sidebar.md | 9 +++++---- docs/img/MAMA_chart.svg | 2 +- docs/img/T3_chart.svg | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 52a8a6dd..f59cf77c 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -3,19 +3,20 @@ * [List of all Indicators](indicators.md "Indicators coverage") * [SMA - Simple Moving Average](SMA.md) - * [RMA - WildeR Moving Average](RMA.md) * [EMA - Exponential Moving Average](EMA.md) * [WMA - Weighted Moving Average](WMA.md) + * [T3 - Tillson T3 Exponential MA](T3.md) * [SMMA - Smoothed Moving Average](SMMA.md) - * [DWMA - Double Weighted Moving Average](DWMA.md) * [TRIMA - Triangular Moving Average](TRIMA.md) + * [DWMA - Double Weighted Moving Average](DWMA.md) * [DEMA - Double Exponential MA](DEMA.md) * [TEMA - Triple Exponential MA](TEMA.md) - * [T3 - Tillson T3 Exponential MA](T3.md) + * [ALMA - Arnaud Legoux Moving Average](ALMA.md) * [HMA - Hull Moving Average](HMA.md) * [HEMA - Hull/Exponential Moving Average](HEMA.md) + * [HWMA - Holt-Winter Moving Average](HWMA.md) + * [MAMA - MESA Adaptive Moving Average](MAMA.md) * [KAMA - Kaufman Adaptive Moving Average](KAMA.md) - * [ALMA - Arnaud Legoux Moving Average](ALMA.md) * [ZLEMA - Zero-Lag Exponential MA](ZLEMA.md) * [JMA - Jurik Moving Average](JMA.md) diff --git a/docs/img/MAMA_chart.svg b/docs/img/MAMA_chart.svg index 3a17f18e..fd2cef35 100644 --- a/docs/img/MAMA_chart.svg +++ b/docs/img/MAMA_chart.svg @@ -1 +1 @@ -020406000.5×10​621×10​62020406002×10​594×10​596×10​598×10​590204060−3×10​45−2×10​45−1×10​450020406001×10​402×10​400204060−1.5×10​19−1×10​19−0.5×10​1900204060−5×10​3805×10​380204060−5×10​2205×10​22020406001×10​482×10​48020406000.5×10​331×10​331.5×10​33020406001×10​692×10​693×10​694×10​690204060−1×10​37−0.5×10​3700204060−1×10​34−0.5×10​3400204060−3×10​33−2×10​33−1×10​3300204060−1×10​28−0.5×10​280020406002×10​244×10​246×10​24020406002×10​224×10​226×10​22 \ No newline at end of file +020406000.20.40.60.81020406000.20.40.60.8102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file diff --git a/docs/img/T3_chart.svg b/docs/img/T3_chart.svg index c1d87c5f..906a89ab 100644 --- a/docs/img/T3_chart.svg +++ b/docs/img/T3_chart.svg @@ -1 +1 @@ -020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file +020406000.20.40.60.81020406000.5102040600102030020406001020300204060−1−0.500.510204060−1−0.500.510204060−1−0.500.510204060−0.4−0.200.20.40204060−1−0.500.50204060−1−0.500.510204060−1−0.500.51020406000.51020406001020300204060−1010204060−1010204060170172174176178 \ No newline at end of file