This commit is contained in:
Miha Kralj
2022-11-28 07:11:58 -08:00
parent 58694a9600
commit 3aaa1c95c6
9 changed files with 720 additions and 8 deletions
+38
View File
@@ -0,0 +1,38 @@
# EMA: Exponential Moving Average
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)
## Calculation
There is an adopted practice to calculate $SMA$ when $n < period$.
$$
EMA_n = \left\{ \begin{array}{cl}
\frac{1}{p}\left( data_{n}-data_{n-p}\right)+SMA_{n-1} & : \ n \leq period \\
{k}\times ({data_{n}} - EMA_{n-1}) + EMA_{n-1} & : \ x > period
\end{array} \right.
$$
## Implementation
``` csharp
EMA_Series mean = new(source: data, period: p, useNaN: false);
```
- `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)
## References
+6 -8
View File
@@ -17,24 +17,22 @@ $$
``` csharp
SMA_Series mean = new(source: data, period: p, useNaN: false);
QuanTA fluent = data.SMA(period: p);
```
## Parameters
- `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)
## Sample chart
picture of SMA
## Comparison & Validation
Validation tests
Performance tests
## Visual analysis
![Alt text](./img/SMA_chart.svg)
## References
- https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/simple-moving-average-sma/
+5
View File
@@ -0,0 +1,5 @@
* [Home](/)
* [Indicators](indicators.md "Indocators coverage")
* [SMA - Simple Moving Average](SMA.md "SMA - Simple Moving Average")
+251
View File
@@ -0,0 +1,251 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div><div></div><div></div><div></div></div>"
]
},
"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<int> x = Enumerable.Range(-cut,96).ToList<int>();\n",
"GenericChart.GenericChart ch1a = Chart2D.Chart.Line<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<IEnumerable<GenericChart.GenericChart>>(8,2).Invoke(chart1).WithSize(1000,2200).WithMargin(Margin.init<int, int, int, int, int, bool>(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
}
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 154 KiB

+242
View File
@@ -0,0 +1,242 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div><div></div><div></div><div></div></div>"
]
},
"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<int> x = Enumerable.Range(-cut,96).ToList<int>();\n",
"GenericChart.GenericChart ch1a = Chart2D.Chart.Line<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<int,double,bool>(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<IEnumerable<GenericChart.GenericChart>>(8,2).Invoke(chart1).WithSize(1000,2200).WithMargin(Margin.init<int, int, int, int, int, bool>(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
}
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 153 KiB

+2
View File
@@ -13,6 +13,8 @@
<div id="app"></div>
<script>
window.$docsify = {
loadSidebar: true,
subMaxLevel: 1,
name: '',
repo: '',
latex: {
+174
View File
@@ -0,0 +1,174 @@
# Coverage
⭐= Calculation is validated against one or many TA libraries
✔️= Calculation exists but has no cross-validation tests
⛔= Not implemented (yet)
| **BASIC TRANSFORMS** | **QuanTAlib** | **TA-LIB** | **Skender** | **Pandas TA** | **Tulip** |
|--|:--:|:--:|:--:|:--:|:--:|
| OC2 - (Open+Close)/2 | `.OC2` || CandlePart.OC2 ||
| HL2 - Median Price | `.HL2` | MEDPRICE | CandlePart.HL2 | hl2 |
| HLC3 - Typical Price | `.HLC3` | TYPPRICE | CandlePart.HLC3 | hlc3 |
| OHL3 - (Open+High+Low)/3 | `.OHL3` || CandlePart.OHL3 ||
| OHLC4 - Average Price | `.OHLC4` | AVGPRICE | CandlePart.OHLC4 | ohlc4 | avgprice |
| HLCC4 - Weighted Price | `.HLCC4` | WCLPRICE | CandlePart.HLCC4 ||
| MIDPOINT - Midpoint value | `MIDPOINT_Series` | MIDPOINT || midpoint |
| MIDPRICE - Midpoint price | `MIDPRICE_Series` | MIDPRICE || midprice |
| MAX - Max value | `MAX_Series` | MAX ||| max |
| MIN - Min value | `MIN_Series` | MIN ||| min |
| SUM - Summation | `SUM_Series` | SUM ||| sum |
| ADD - Addition | `ADD_Series` | ADD ||| add |
| SUB - Subtraction | `SUB_Series` | SUB ||| sub |
| MUL - Multiplication | `MUL_Series` | MUL ||| mul |
| DIV - Division | `DIV_Series` | DIV ||| div |
|||||
| **STATISTICS & NUMERICAL ANALYSIS** |
||||||
| BIAS - Bias | `BIAS_Series` ||| bias |
| CORR - Pearson's Correlation Coefficient | `CORR_Series` | CORREL | GetCorrelation ||
| COVAR - Covariance | `COVAR_Series` || GetCorrelation ||
| DECAY - Linear Decay ||||| decay |
| EDECAY - Exponential Decay ||||| edecay |
| ENTROPY - Entropy | `ENTROPY_Series` ||| entropy |
| KURTOSIS - Kurtosis | `KURT_Series` ||| kurtosis |
| LINREG - Linear Regression | `LINREG_Series` || GetSlope ||
| MAD - Mean Absolute Deviation | `MAD_Series` || GetSma | mad |
| MAPE - Mean Absolute Percent Error | `MAPE_Series` || GetSma ||
| MED - Median value | `MED_Series` ||| median |
| MSE - Mean Squared Error | `MSE_Series` || GetSma ||
| SKEW - Skewness |||| skew |
| SDEV - Standard Deviation (Volatility) | `SDEV_Series` | STDDEV | GetStdDev | stdev |
| SSDEV - Sample Standard Deviation | `SSDEV_Series` ||| stdev |
| SMAPE - Symmetric Mean Absolute Percent Error | `SMAPE_Series` ||||
| VAR - Population Variance | `VAR_Series` | VAR || variance |
| SVAR - Sample Variance | `SVAR_Series` ||| variance |
| QUANTILE - Quantile |||| quantile |
| WMAPE - Weighted Mean Absolute Percent Error | `WMAPE_Series` ||||
| ZSCORE - Number of standard deviations from mean | `ZSCORE_Series` || GetStdDev | zscore |
||||||
| **TREND INDICATORS & AVERAGES** |
||||||
| AFIRMA - Autoregressive Finite Impulse Response Moving Average |||||
| ALMA - Arnaud Legoux Moving Average | `ALMA_Series` || GetAlma | alma |
| ARIMA - Autoregressive Integrated Moving Average |||||
| DEMA - Double EMA Average | `DEMA_Series` | DEMA | GetDema | dema | dema |
| EMA - Exponential Moving Average | `EMA_Series` | EMA | GetEma | ema | ema |
| EPMA - Endpoint Moving Average ||| GetEpma ||
| FRAMA - Fractal Adaptive Moving Average |||||
| FWMA - Fibonacci's Weighted Moving Average |||| fwma |
| HILO - Gann High-Low Activator |||| hilo |
| 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 |
| 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 |
| LSMA - Least Squares Moving Average |||||
| MACD - Moving Average Convergence/Divergence | `MACD_Series` | MACD | GetMacd | macd |
| MAMA - MESA Adaptive Moving Average | `MAMA_Series` | MAMA | GetMama ||
| MCGD - McGinley Dynamic |||| mcgd |
| MMA - Modified Moving Average |||||
| PPMA - Pivot Point Moving Average |||||
| PWMA - Pascal's Weighted Moving Average |||| pwma |
| RMA - WildeR's Moving Average | `RMA_Series` ||| rma |
| SINWMA - Sine Weighted Moving Average |||| sinwma |
| ⭐ [SMA - Simple Moving Average](SMA.md) | `SMA_Series` | ⭐ SMA | ⭐ GetSma | ⭐ sma | ⭐ sma |
| SMMA - Smoothed Moving Average | `SMMA_Series` || GetSmma ||
| 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 |
| TEMA - Triple EMA Average | `TEMA_Series` | TEMA | GetTema | tema |
| TRIMA - Triangular Moving Average | `TRIMA_Series` | TRIMA || trima |
| TSF - Time Series Forecast || TSF |||
| VIDYA - Variable Index Dynamic Average |||| vidya |
| VORTEX - Vortex Indicator |||| vortex |
| WMA - Weighted Moving Average | `WMA_Series` | WMA | GetWma | wma |
| ZLEMA - Zero Lag EMA Average | `ZLEMA_Series` ||| zlma |
||||||
| **VOLATILITY INDICATORS** |
||||||
| ADL - Chaikin Accumulation Distribution Line | `ADL_Series` | AD | GetAdl | ad | ad |
| ADOSC - Chaikin Accumulation Distribution Oscillator | `ADOSC_Series` | ADOSC| GetAdl | adosc | adosc |
| ATR - Average True Range | `ATR_Series` | ATR | GetAtr | atr | atr |
| ATRP - Average True Range Percent | `ATRP_Series` || GetAtr ||
| BETA - Beta coefficient || BETA | GetBeta ||
| BBANDS - Bollinger Bands® | `BBANDS_Series` | BBANDS | GetBollingerBands || bbands |
| CHAND - Chandelier Exit ||| GetChandelier ||
| CRSI - Connor RSI ||| GetConnorsRsi ||
| CVI - Chaikins Volatility ||||| cvi |
| DON - Donchian Channels ||| GetDonchian ||
| FCB - Fractal Chaos Bands ||| GetFcb ||
| FISHER - Fisher Transform ||| GetFcb || fisher |
| HV - Historical Volatility |||||
| ICH - Ichimoku ||| GetIchimoku ||
| KEL - Keltner Channels ||| GetKeltner ||
| NATR - Normalized Average True Range || NATR | GetAtr ||
| CHN - Price Channel Indicator |||||
| RSI - Relative Strength Index | `RSI_Series` | RSI | GetRsi | rsi |
| SAR - Parabolic Stop and Reverse || SAR | GetParabolicSar ||
| SRSI - Stochastic RSI || STOCHRSI | GetStochRsi ||
| STARC - Starc Bands |||||
| TR - True Range | `TR_Series` | TRANGE | GetTr | true_range |
| UI - Ulcer Index |||||
| VSTOP - Volatility Stop |||||
||||||
| **MOMENTUM INDICATORS & OSCILLATORS** |
||||||
| AC - Acceleration Oscillator |||||
| ADX - Average Directional Movement Index || ADX | GetAdx || adx |
| ADXR - Average Directional Movement Index Rating || ADXR | GetAdx || adxr |
| AO - Awesome Oscillator ||| GetAwesome || ao |
| APO - Absolute Price Oscillator || APO ||| apo |
| AROON - Aroon oscillator || AROON | GetAroon || aroon |
| BOP - Balance of Power || BOP | GetBop || bop |
| CCI - Commodity Channel Index | `CCI_Series` | CCI | GetCci || cci |
| CFO - Chande Forcast Oscillator |||||
| CMO - Chande Momentum Oscillator || CMO | GetCmo || cmo |
| COG - Center of Gravity |||||
| COPPOCK - Coppock Curve |||||
| CTI - Ehler's Correlation Trend Indicator |||||
| DPO - Detrended Price Oscillator ||| GetDpo ||
| DMI - Directional Movement Index || DX | GetAdx ||
| EFI - Elder Ray's Force Index ||| GetElderRay ||
| FOSC - Forecast oscillator ||||| fosc |
| GAT - Alligator oscillator ||| GetGator ||
| HURST - Hurst Exponent ||| GetHurst ||
| KRI - Kairi Relative Index |||||
| KVO - Klinger Volume Oscillator |||||
| MFI - Money Flow Index || MFI | GetMfi ||
| MOM - Momentum || MOM |||
| NVI - Negative Volume Index |||||
| PO - Price Oscillator |||||
| PPO - Percentage Price Oscillator || PPO |||
| PMO - Price Momentum Oscillator |||||
| PVI - Positive Volume Index |||||
| ROC - Rate of Change || MOM | GetRoc ||
| RVGI - Relative Vigor Index |||||
| SMI - Stochastic Momentum Index |||||
| STC - Schaff Trend Cycle |||||
| STOCH - Stochastic Oscillator || STOCH | GetStoch ||
| TRIX - 1-day ROC of TEMA || TRIX | GetTrix ||
| TSI - True Strength Index |||||
| UO - Ultimate Oscillator || ULTOSC | GetUltimate ||
| WILLR - Larry Williams' %R || WILLR | GetWilliamsR ||
| WGAT - Williams Alligator |||||
||||||
| **VOLUME INDICATORS** |
||||||
| AOBV - Archer On-Balance Volume |||||
| CMF - Chaikin Money Flow |||||
| EOM - Ease of Movement ||||| emv |
| KVO - Klinger Volume Oscilaltor ||||| kvo |
| OBV - On-Balance Volume | `OBV_Series` | 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 |||||