diff --git a/Source/Indicators/ZLEMA_Series.cs b/Source/Indicators/ZLEMA_Series.cs index be2913f7..657bfbc7 100644 --- a/Source/Indicators/ZLEMA_Series.cs +++ b/Source/Indicators/ZLEMA_Series.cs @@ -36,9 +36,10 @@ public class ZLEMA_Series : Single_TSeries_Indicator public override void Add((System.DateTime t, double v) TValue, bool update) { - int _lag = (int)((_p - 1) * 0.5); - _lag = (this.Count - _lag < 0) ? 0 : this.Count - _lag; - double _zl = TValue.v + (TValue.v - _data[_lag].v); + int _lag = (int)((_p-1) * 0.5); + _lag = (this.Count-_lag < 0) ? 0 : this.Count-_lag; + double _zl = TValue.v + (TValue.v - _data[_lag].v); + double _ema = 0; if (update) { this._lastema = this._lastlastema; } @@ -59,7 +60,7 @@ public class ZLEMA_Series : Single_TSeries_Indicator } else { - _ema = TValue.v * this._k + this._lastema * this._k1m; + _ema = _zl * this._k + this._lastema * this._k1m; } this._lastlastema = this._lastema; diff --git a/docs/coverage.md b/docs/coverage.md deleted file mode 100644 index f389e47c..00000000 --- a/docs/coverage.md +++ /dev/null @@ -1,164 +0,0 @@ -# Coverage of indicators - -✔️= Calculation exists in QuanTAlib - -⭐= Calculation is validated against other TA libraries - -⛔= Not implemented in QuanTAlib (yet) - -| **BASIC TRANSFORMS** | **QuanTAlib** | **TA-LIB** | **Skender** | -|--|:--:|:--:|:--:| -| ✔️ OC2 - (Open+Close)/2 |️ .OC2 || ️GetBaseQuote | -| ⭐ HL2 - Median Price | .HL2 | MEDPRICE | ️GetBaseQuote | -| ⭐ HLC3 - Typical Price | .HLC3 | TYPPRICE || -| ✔️ OHL3 - (Open+High+Low)/3 | .OHL3 ||| -| ⭐ OHLC4 - Average Price | .OHLC4 | AVGPRICE |️ GetBaseQuote | -| ⭐ HLCC4 - Weighted Price | .HLCC4 | WCLPRICE || -| ✔️ ZL - De-lagged price (Zero-Lag) | ZL_Series ||| -| ⭐ MAX - Max value | MAX_Series | MAX || -| ⛔ MID - Midpoint value || MIDPOINT || -| ⛔ MIDP - Midpoint price || MIDPRICE || -| ⭐ MIN - Min value | MIN_Series | MIN || -| ⭐ ADD - Addition | ADD_Series | ADD || -| ⭐ SUB - Subtraction | SUB_Series | SUB || -| ⭐ MUL - Multiplication | MUL_Series | MUL || -| ⭐ DIV - Division | DIV_Series | DIV || -||||| -| **STATISTICS & NUMERICAL ANALYSIS** | **QuanTAlib** | **TA-LIB** | **Skender** | -| ✔️ BIAS - Bias | BIAS_Series ||| -| ⛔ CORREL - Pearson's Correlation Coefficient || CORREL | GetCorrelation | -| ⛔ COVAR - Covariance ||| GetCorrelation | -| ✔️ ENTP - Entropy | ENTP_Series ||| -| ✔️ KURT - Kurtosis | KURT_Series ||| -| ⭐ LINREG - Linear Regression | LINREG_Series || GetSlope | -| ⭐ MAD - Mean Absolute Deviation | MAD_Series || GetSma | -| ⭐ MAPE - Mean Absolute Percent Error | MAPE_Series || GetSma | -| ✔️ MED - Median value | MED_Series ||| -| ✔️ MSE - Mean Squared Error | MSE_Series || GetSma | -| ⛔ SKEW - Skewness |||| -| ⭐ SDEV - Standard Deviation (Volatility) | SDEV_Series ||| -| ✔️ SSDEV - Sample Standard Deviation | SSDEV_Series ||| -| ✔️ SMAPE - Symmetric Mean Absolute Percent Error | SMAPE_Series ||| -| ✔️ VAR - Population Variance | VAR_Series ||| -| ✔️ SVAR - Sample Variance | SVAR_Series ||| -| ⛔ QUANT - Quantile |||| -| ✔️ WMAPE - Weighted Mean Absolute Percent Error | WMAPE_Series ||| -| ⛔ ZSCORE - Number of standard deviations from mean |||| -||||| -| **TREND INDICATORS & AVERAGES** | **QuanTAlib** | **TA-LIB** | **Skender** | -| ⛔ AFIRMA - Autoregressive Finite Impulse Response Moving Average |||| -| ⭐ ALMA - Arnaud Legoux Moving Average | ALMA_Series || GetAlma | -| ⛔ ARIMA - Autoregressive Integrated Moving Average |||| -| ⭐ DEMA - Double EMA Average | DEMA_Series | DEMA | GetDema | -| ⭐ EMA - Exponential Moving Average | EMA_Series || GetEma | -| ⛔ EPMA - Endpoint Moving Average ||| GetEpma | -| ⛔ FWMA - Fibonacci's Weighted Moving Average |||| -| ✔️ HEMA - Hull/EMA Average | HEMA_Series ||| -| ⛔ Hilbert Transform Instantaneous Trendline || HT_TRENDLINE | GetHtTrendline | -| ⭐ HMA - Hull Moving Average | HMA_Series || GetHma | -| ⛔ HWMA - Holt-Winter Moving Average |||| -| ✔️ JMA - Jurik Moving Average | JMA_Series ||| -| ⭐ KAMA - Kaufman's Adaptive Moving Average | KAMA_Series | KAMA | GetKama | -| ⛔ LSMA - Least Squares Moving Average |||| -| ⭐ MACD - Moving Average Convergence/Divergence | MACD_Series | MACD | GetMacd | -| ⛔ MAMA - MESA Adaptive Moving Average || MAMA | GetMama | -| ⛔ MMA - Modified Moving Average |||| -| ⛔ PPMA - Pivot Point Moving Average |||| -| ⛔ PWMA - Pascal's Weighted Moving Average |||| -| ✔️ RMA - WildeR's Moving Average | RMA__Series ||| -| ⛔ SINWMA - Sine Weighted Moving Average |||| -| ⭐ SMA - Simple Moving Average | SMA_Series ||| -| ⭐ SMMA - Smoothed Moving Average | SMMA_Series ||| -| ⛔ SSF - Ehler's Super Smoother Filter |||| -| ⛔ SUP - Supertrend |||| -| ⛔ SWMA - Symmetric Weighted Moving Average |||| -| ⛔ T3 - Tillson T3 Moving Average |||| -| ⭐ TEMA - Triple EMA Average | TEMA_Series ||| -| ⛔ TRIMA - Triangular Moving Average |||| -| ⛔ VIDYA - Variable Index Dynamic Average |||| -| ⭐ WMA - Weighted Moving Average | WMA_Series ||| -| ✔️ ZLEMA - Zero Lag EMA Average | ZLEMA_Series ||| -||||| -| **VOLATILITY INDICATORS** | **QuanTAlib** | **TA-LIB** | **Skender** | -| ⭐ ADL - Chaikin Accumulation Distribution Line | ADL_Series | AD | GetAdl | -| ⭐ ADOSC - Chaikin Accumulation Distribution Oscillator | ADOSC_Series | ADOSC| GetAdl | -| ⭐ ATR - Average True Range | ATR_Series | ATR | GetAtr | -| ⭐ ATRP - Average True Range Percent | ATRP_Series || GetAtr | -| ✔️ BETA - Beta coefficient || BETA | GetBeta | -| ⭐ BBANDS - Bollinger Bands® | BBANDS_Series | BBANDS | GetBollingerBands | -| ⛔ CRSI - Connor RSI ||| GetConnorsRsi | -| ⛔ DON - Donchian Channels ||| GetDonchian | -| ⛔ FCB - Fractal Chaos Bands ||| GetFcb | -| ⛔ HV - Historical Volatility |||| -| ⛔ ICH - Ichimoku ||| GetIchimoku | -| ⛔ KEL - Keltner Channels ||| GetKeltner | -| ⛔ NATR - Normalized Average True Range || NATR | GetAtr | -| ⭐ RSI - Relative Strength Index | RSI_Series || -| ⛔ SAR - Parabolic Stop and Reverse || SAR | GetParabolicSar | -| ⛔ SRSI - Stochastic RSI |||| -| ⛔ STARC - Starc Bands |||| -| ⭐ TR - True Range | TR_Series ||| -| ⛔ UI - Ulcer Index |||| -| ⛔ VSTOP - Volatility Stop |||| -||||| -| **MOMENTUM INDICATORS & OSCILLATORS** | **QuanTAlib** | **TA-LIB** | **Skender** | -| ⛔ AC - Acceleration Oscillator |||| -| ⛔ ADX - Average Directional Movement Index || ADX | GetAdx | -| ⛔ ADXR - Average Directional Movement Index Rating || ADXR | GetAdx | -| ⛔ AO - Awesome Oscillator ||| GetAwesome | -| ⛔ APO - Absolute Price Oscillator || APO || -| ⛔ AROON - Aroon oscillator || AROON | GetAroon | -| ⛔ BOP - Balance of Power || BOP | GetBop | -| ⭐ CCI - Commodity Channel Index | CCI_Series | CCI | GetCci | -| ⛔ CFO - Chande Forcast Oscillator |||| -| ⛔ CMF - Chaikin Money Flow |||| -| ⛔ CMO - Chande Momentum Oscillator || CMO | GetCmo | -| ⛔ COG - Center of Gravity |||| -| ⛔ CTI - Ehler's Correlation Trend Indicator |||| -| ⛔ DPO - Detrended Price Oscillator ||| GetDpo | -| ⛔ DMI - Directional Movement Index || DX | GetAdx | -| ⛔ EFI - Elder Ray's Force Index ||| GetElderRay | -| ⛔ GAT - Alligator oscillator ||| GetGator | -| ⛔ HURST - Hurst Exponent ||| GetHurst | -| ⛔ KRI - Kairi Relative Index |||| -| ⛔ KVO - Klinger Volume Oscillator |||| -| ⛔ MFI - Money Flow Index || MFI | GetMfi | -| ⛔ ROC - Rate of Change (Momentum) || MOM | GetRoc | -| ⛔ NVI - Negative Volume Index |||| -| ⛔ PO - Price Oscillator |||| -| ⛔ PPO - Percentage Price Oscillator || PPO || -| ⛔ PMO - Price Momentum Oscillator |||| -| ⛔ PVI - Positive Volume Index |||| -| ⛔ RVGI - Relative Vigor Index |||| -| ⛔ SMI - Stochastic Momentum Index |||| -| ⛔ STOCH - Stochastic Oscillator |||| -| ⛔ TRIX - 1-day ROC of TEMA |||| -| ⛔ TSI - True Strength Index |||| -| ⛔ UO - Ultimate Oscillator |||| -| ⛔ WGAT - Williams Alligator |||| -||||| -| **VOLUME INDICATORS** | **QuanTAlib** | **TA-LIB** | **Skender** | -| ⛔ AOBV - Archer On-Balance Volume |||| -| ⛔ OBV - On-Balance Volume || OBV | GetObv | -| ⛔ PRS - Price Relative Strength ||| -| ⛔ PVOL - Price-Volume |||| -| ⛔ PVO - Percentage Volume Oscillator |||| -| ⛔ PVR - Price Volume Rank |||| -| ⛔ PVT - Price Volume Trend |||| -| ⛔ VP - Volume Profile |||| -| ⛔ VWAP - Volume Weighted Average Price |||| -| ⛔ VWMA - Volume Weighted Moving Average |||| -||||| -|**Unsorted** | **QuanTAlib** | **TA-LIB** | **Skender** | -| ⛔ CHN - Price Channel |||| -| ⛔ COPPOCK - Coppock Curve |||| -| ⛔ EOM - Ease of Movement |||| -| ⛔ HILO - Gann High-Low Activator |||| -| ⛔ HT - HT Trendline |||| -| ⛔ MCGD - McGinley Dynamic |||| -| ⛔ STC - Schaff Trend Cycle |||| -| ⛔ WILLR - Larry Williams' %R |||| -| ⛔ VOR - Vortex Indicator |||| -| ⛔ PVT - Pivot Points |||| -| ⛔ KDJ - KDJ Index |||| -| ⛔ CHAND - Chandelier Exit |||| diff --git a/docs/crossovers.ipynb b/docs/crossovers.ipynb new file mode 100644 index 00000000..0e185e25 --- /dev/null +++ b/docs/crossovers.ipynb @@ -0,0 +1,157 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "vscode": { + "languageId": "dotnet-interactive.csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/markdown": [ + "Loading extensions from `Plotly.NET.Interactive.dll`" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: QuanTAlib;\"\n", + "#r \"nuget: Plotly.NET;\"\n", + "#r \"nuget: Plotly.NET.Interactive;\"\n", + "\n", + "using QuanTAlib;\n", + "using Plotly.NET;\n", + "using Plotly.NET.LayoutObjects;\n" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "vscode": { + "languageId": "dotnet-interactive.csharp" + } + }, + "outputs": [], + "source": [ + "Yahoo_Feed data = new(Symbol: \"MSFT\", Period: 200);\n", + "ZLEMA_Series calc1 = new(data.OHLC4,20,true);\n", + "HMA_Series calc2 = new(data.OHLC4,20, true);\n", + "HEMA_Series calc3 = new(data.OHLC4,20, true);" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "vscode": { + "languageId": "dotnet-interactive.csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "
\n", + "
\r\n", + "\r\n", + "\n", + " \n", + "
\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "var layout = Layout.init( \n", + " PlotBGColor : Color.fromString(\"#1e1e1e\"),\n", + " PaperBGColor : Color.fromString(\"#1e1e1e\"),\n", + " Font:Font.init(Size:10, Color: Color.fromString(\"#ffffff\")));\n", + "\n", + "var yAxis = LinearAxis.init(\n", + " GridColor:Color.fromString(\"#252525\")); \n", + "\n", + "var candles = Chart2D.Chart.Candlestick(data.Open.v, data.High.v, data.Low.v, data.Close.v, data.Open.t, \"\");\n", + "var line1 = Chart2D.Chart.Line(calc1.t, calc1.v,false,\"\").WithLineStyle(Width: 2, Color: Color.fromString(\"yellow\"));\n", + "var line2 = Chart2D.Chart.Line(calc2.t, calc2.v, false,\"\").WithLineStyle(Width: 3, Color: Color.fromString(\"red\"));\n", + "var line3 = Chart2D.Chart.Line(calc3.t, calc3.v, false,\"\").WithLineStyle(Width: 2, Color: Color.fromString(\"blue\"));\n", + "var chart = Chart.Combine(new []{candles, line1, line2, line3})\n", + " .WithSize(1200,600)\n", + " .WithMargin(Margin.init(30,10,40,30,1,false))\n", + " .WithXAxisRangeSlider(RangeSlider.init(Visible:false))\n", + " .WithYAxis(yAxis)\n", + " .WithXAxis(yAxis)\n", + " .WithTitle(\"MSFT\")\n", + " .WithLayout(layout);\n", + "\n", + "chart" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "file_extension": ".cs", + "mimetype": "text/x-csharp", + "name": "C#", + "pygments_lexer": "csharp", + "version": "9.0" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/getting_started.ipynb b/docs/getting_started.ipynb index f13dbe9d..ede92014 100644 --- a/docs/getting_started.ipynb +++ b/docs/getting_started.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -28,18 +28,21 @@ }, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "index\t data\t\t sma(data)\t ema(sma(data))\t wma(ema(sma(data)))\n", - "0\t 2022-11-01\t 150.65\t\t 150.65\t\t NaN\n", - "1\t 2022-11-02\t 147.84\t\t 149.25\t\t NaN\n", - "2\t 2022-11-03\t 144.85\t\t 147.78\t\t NaN\n", - "3\t 2022-11-04\t 143.24\t\t 146.64\t\t NaN\n", - "4\t 2022-11-07\t 142.37\t\t 145.79\t\t 147.20\n", - "5\t 2022-11-08\t 140.14\t\t 143.91\t\t 145.83\n", - "6\t 2022-11-09\t 138.11\t\t 141.97\t\t 144.26\n", - "7\t 2022-11-10\t 139.71\t\t 141.22\t\t 142.93\n" + "data": { + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "ename": "Error", + "evalue": "(3,1): error CS0246: The type or namespace name 'Yahoo_Feed' could not be found (are you missing a using directive or an assembly reference?)\r\n(10,15): error CS0019: Operator '<' cannot be applied to operands of type 'int' and 'method group'", + "output_type": "error", + "traceback": [ + "(3,1): error CS0246: The type or namespace name 'Yahoo_Feed' could not be found (are you missing a using directive or an assembly reference?)\r\n", + "(10,15): error CS0019: Operator '<' cannot be applied to operands of type 'int' and 'method group'" ] } ], diff --git a/docs/readme.md b/docs/readme.md index bac062ff..d98f2c3b 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -27,7 +27,7 @@ QuanTAlib does not focus on sources of OHLCV quotes. There are some basic data f See [Getting Started](https://github.com/mihakralj/QuanTAlib/blob/main/Docs/getting_started.ipynb) .NET interactive notebook to get a feel how library works. Developers can use QuanTAlib in .NET interactive or in console apps, but the best usage of the library is withing C#-enabled trading platforms - see **QuanTower_Charts** folder for Quantower examples. -# Coverage +## Coverage ⭐= Calculation is validated against other TA libraries @@ -67,7 +67,7 @@ See [Getting Started](https://github.com/mihakralj/QuanTAlib/blob/main/Docs/gett | ⛔ SKEW - Skewness |||| | ⭐ SDEV - Standard Deviation (Volatility) | SDEV_Series ||| | ✔️ SSDEV - Sample Standard Deviation | SSDEV_Series ||| -| ✔️ SMAPE - Symmetric Mean Absolute Percent Error | SMAPE_Series ||| +| ✔️ SMAPE - Symmetric Mean Absolute Percent Error | SMAPE_Series ||| | ✔️ VAR - Population Variance | VAR_Series ||| | ✔️ SVAR - Sample Variance | SVAR_Series ||| | ⛔ QUANT - Quantile ||||