mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-06 13:07:44 +00:00
390 lines
177 KiB
Plaintext
390 lines
177 KiB
Plaintext
|
|
{
|
||
|
|
"cells": [
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 18,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>QuanTAlib, 0.2.0</span></li></ul></div></div>"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"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;"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 19,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
},
|
||
|
|
"polyglot_notebook": {
|
||
|
|
"kernelName": "csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"<div><div id=\"d6ed8adf-ec28-4b73-8d34-423a356f40b7\"><!-- Plotly chart will be drawn inside this DIV --></div><script type=\"text/javascript\">\r\n",
|
||
|
|
"var renderPlotly_d6ed8adfec284b738d34423a356f40b7 = function() {\r\n",
|
||
|
|
" var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.18.1.min'}}) || require;\r\n",
|
||
|
|
" fsharpPlotlyRequire(['plotly'], function(Plotly) {\r\n",
|
||
|
|
" var data = [{\"type\":\"candlestick\",\"name\":\"SPY\",\"x\":[\"2022-01-31T14:30:00\",\"2022-02-01T14:30:00\",\"2022-02-02T14:30:00\",\"2022-02-03T14:30:00\",\"2022-02-04T14:30:00\",\"2022-02-07T14:30:00\",\"2022-02-08T14:30:00\",\"2022-02-09T14:30:00\",\"2022-02-10T14:30:00\",\"2022-02-11T14:30:00\",\"2022-02-14T14:30:00\",\"2022-02-15T14:30:00\",\"2022-02-16T14:30:00\",\"2022-02-17T14:30:00\",\"2022-02-18T14:30:00\",\"2022-02-22T14:30:00\",\"2022-02-23T14:30:00\",\"2022-02-24T14:30:00\",\"2022-02-25T14:30:00\",\"2022-02-28T14:30:00\",\"2022-03-01T14:30:00\",\"2022-03-02T14:30:00\",\"2022-03-03T14:30:00\",\"2022-03-04T14:30:00\",\"2022-03-07T14:30:00\",\"2022-03-08T14:30:00\",\"2022-03-09T14:30:00\",\"2022-03-10T14:30:00\",\"2022-03-11T14:30:00\",\"2022-03-14T13:30:00\",\"2022-03-15T13:30:00\",\"2022-03-16T13:30:00\",\"2022-03-17T13:30:00\",\"2022-03-18T13:30:00\",\"2022-03-21T13:30:00\",\"2022-03-22T13:30:00\",\"2022-03-23T13:30:00\",\"2022-03-24T13:30:00\",\"2022-03-25T13:30:00\",\"2022-03-28T13:30:00\",\"2022-03-29T13:30:00\",\"2022-03-30T13:30:00\",\"2022-03-31T13:30:00\",\"2022-04-01T13:30:00\",\"2022-04-04T13:30:00\",\"2022-04-05T13:30:00\",\"2022-04-06T13:30:00\",\"2022-04-07T13:30:00\",\"2022-04-08T13:30:00\",\"2022-04-11T13:30:00\",\"2022-04-12T13:30:00\",\"2022-04-13T13:30:00\",\"2022-04-14T13:30:00\",\"2022-04-18T13:30:00\",\"2022-04-19T13:30:00\",\"2022-04-20T13:30:00\",\"2022-04-21T13:30:00\",\"2022-04-22T13:30:00\",\"2022-04-25T13:30:00\",\"2022-04-26T13:30:00\",\"2022-04-27T13:30:00\",\"2022-04-28T13:30:00\",\"2022-04-29T13:30:00\",\"2022-05-02T13:30:00\",\"2022-05-03T13:30:00\",\"2022-05-04T13:30:00\",\"2022-05-05T13:30:00\",\"2022-05-06T13:30:00\",\"2022-05-09T13:30:00\",\"2022-05-10T13:30:00\",\"2022-05-11T13:30:00\",\"2022-05-12T13:30:00\",\"2022-05-13T13:30:00\",\"2022-05-16T13:30:00\",\"2022-05-17T13:30:00\",\"2022-05-18T13:30:00\",\"2022-05-19T13:30:00\",\"2022-05-20T13:30:00\",\"2022-05-23T13:30:00\",\"2022-05-24T13:30:00\",\"2022-05-25T13:30:00\",\"2022-05-26T13:30:00\",\"2022-05-27T13:30:00\",\"2022-05-31T13:30:00\",\"2022-06-01T13:30:00\",\"2022-06-02T13:30:00\",\"2022-06-03T13:30:00\",\"2022-06-06T13:30:00\",\"2022-06-07T13:30:00\",\"2022-06-08T13:30:00\",\"2022-06-09T13:30:00\",\"2022-06-10T13:30:00\",\"2022-06-13T13:30:00\",\"2022-06-14T13:30:00\",\"2022-06-15T13:30:00\",\"2022-06-16T13:30:00\",\"2022-06-17T13:30:00\",\"2022-06-21T13:30:00\",\"2022-06-22T13:30:00\",\"2022-06-23T13:30:00\",\"2022-06-24T13:30:00\",\"2022-06-27T13:30:00\",\"2022-06-28T13:30:00\",\"2022-06-29T13:30:00\",\"2022-06-30T13:30:00\",\"2022-07-01T13:30:00\",\"2022-07-05T13:30:00\",\"2022-07-06T13:30:00\",\"2022-07-07T13:30:00\",\"2022-07-08T13:30:00\",\"2022-07-11T13:30:00\",\"2022-07-12T13:30:00\",\"2022-07-13T13:30:00\",\"2022-07-14T13:30:00\",\"2022-07-15T13:30:00\",\"2022-07-18T13:30:00\",\"2022-07-19T13:30:00\",\"2022-07-20T13:30:00\",\"2022-07-21T13:30:00\",\"2022-07-22T13:30:00\",\"2022-07-25T13:30:00\",\"2022-07-26T13:30:00\",\"2022-07-27T13:30:00\",\"2022-07-28T13:30:00\",\"2022-07-29T13:30:00\",\"2022-08-01T13:30:00\",\"2022-08-02T13:30:00\",\"2022-08-03T13:30:00\",\"2022-08-04T13:30:00\",\"2022-08-05T13:30:00\",\"2022-08-08T13:30:00\",\"2022-08-09T13:30:00\",\"2022-08-10T13:30:00\",\"2022-08-11T13:30:00\",\"2022-08-12T13:30:00\",\"2022-08-15T13:30:00\",\"2022-08-16T13:30:00\",\"2022-08-17T13:30:00\",\"2022-08-18T13:30:00\",\"2022-08-19T13:30:00\",\"2022-08-22T13:30:00\",\"2022-08-23T13:30:00\",\"2022-08-24T13:30:00\",\"2022-08-25T13:30:00\",\"2022-08-26T13:30:00\",\"2022-08-29T13:30:00\",\"2022-08-30T13:30:00\",\"2022-08-31T13:30:00\",\"2022-09-01T13:30:00\",\"2022-09-02T13:30:00\",\"2022-09-06T13:30:00\",\"2022-09-07T13:30:00\",\"2022-09-08T13:30:00\",\"2022-09-09T13:30:00\",\"2022-09-12T13:30:00\",\"2022-09-13T13:30:00\",\"2022-09-14T13:30:00\",\"2022-09-15T13:30:00\",\"2022-09-16T13:30:00\",\"2022-09-19T13:30:00\",\"2022-09-20T13:30:00\",\"2022-09-21T13:30:00\",\"2022-09-22T13:30:00\",\"2022-09-23T13:30:00\",\"2022-09-26T13:30:00\",\"2022-09-27T13:30:00\",\"2022-09-28T13:30:00\",\"2022-09
|
||
|
|
" var layout = {\"width\":1200,\"height\":400,\"template\":{\"layout\":{\"title\":{\"x\":0.05},\"font\":{\"color\":\"rgba(42, 63, 95, 1.0)\"},\"paper_bgcolor\":\"rgba(255, 255, 255, 1.0)\",\"plot_bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"autotypenumbers\":\"strict\",\"colorscale\":{\"diverging\":[[0.0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1.0,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0.0,\"ticks\":\"\"}},\"geo\":{\"showland\":true,\"landcolor\":\"rgba(229, 236, 246, 1.0)\",\"showlakes\":true,\"lakecolor\":\"rgba(255, 255, 255, 1.0)\",\"subunitcolor\":\"rgba(255, 255, 255, 1.0)\",\"bgcolor\":\"rgba(255, 255, 255, 1.0)\"},\"mapbox\":{\"style\":\"light\"},\"polar\":{\"bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"radialaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"},\"angularaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"yaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"zaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true}},\"ternary\":{\"aaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"baxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"caxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"bgcolor\":\"rgba(229, 236, 246, 1.0)\"},\"xaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"yaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"shapedefaults\":{\"line\":{\"color\":\"rgba(42, 63, 95, 1.0)\"}},\"colorway\":[\"rgba(99, 110, 250, 1.0)\",\"rgba(239, 85, 59, 1.0)\",\"rgba(0, 204, 150, 1.0)\",\"rgba(171, 99, 250, 1.0)\",\"rgba(255, 161, 90, 1.0)\",\"rgba(25, 211, 243, 1.0)\",\"rgba(255, 102, 146, 1.0)\",\"rgba(182, 232, 128, 1.0)\",\"rgba(255, 151, 255, 1.0)\",\"rgba(254, 203, 82, 1.0)\"]},\"data\":{\"bar\":[{\"marker\":{\"line\":{\"color\":\"rgba(229, 236, 246, 1.0)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"s
|
||
|
|
" var config = {\"responsive\":true};\r\n",
|
||
|
|
" Plotly.newPlot('d6ed8adf-ec28-4b73-8d34-423a356f40b7', data, layout, config);\r\n",
|
||
|
|
" });\r\n",
|
||
|
|
"};\r\n",
|
||
|
|
"if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {\r\n",
|
||
|
|
" var script = document.createElement(\"script\");\r\n",
|
||
|
|
" script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\");\r\n",
|
||
|
|
" script.onload = function(){\r\n",
|
||
|
|
" renderPlotly_d6ed8adfec284b738d34423a356f40b7();\r\n",
|
||
|
|
" };\r\n",
|
||
|
|
" document.getElementsByTagName(\"head\")[0].appendChild(script);\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"else {\r\n",
|
||
|
|
" renderPlotly_d6ed8adfec284b738d34423a356f40b7();\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"</script></div>"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"source": [
|
||
|
|
"string symbol=\"SPY\"; // we'll focus on SPY symbol\n",
|
||
|
|
"int warmup = 50; // we'll allow 50 bars to pass by with no trading - for warm-up\n",
|
||
|
|
"Yahoo_Feed bars = new(symbol,350); //collect bars of symbol from Yahoo feed\n",
|
||
|
|
"TSeries data = bars.Close; //we need just one average value - (Open+High+Low+CLose)/4\n",
|
||
|
|
"\n",
|
||
|
|
"//make a chart\n",
|
||
|
|
"var d = Chart2D.Chart.Candlestick<double, double, double, double, DateTime, string>(bars.Open.v.Skip(warmup).ToList(), bars.High.v.Skip(warmup).ToList(), \n",
|
||
|
|
"bars.Low.v.Skip(warmup).ToList(), bars.Close.v.Skip(warmup).ToList(), bars.Open.t.Skip(warmup).ToList(), symbol)\n",
|
||
|
|
" .WithSize(1200,400).WithMargin(Margin.init<int, int, int, int, int, bool>(30,10,40,30,1,false)).WithXAxisRangeSlider(RangeSlider.init(Visible:false)).WithTitle(symbol);\n",
|
||
|
|
"d"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 20,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"<div><div id=\"b34d57f3-6c88-49a8-8a00-ad8f5b0c3552\"><!-- Plotly chart will be drawn inside this DIV --></div><script type=\"text/javascript\">\r\n",
|
||
|
|
"var renderPlotly_b34d57f36c8849a88a00ad8f5b0c3552 = function() {\r\n",
|
||
|
|
" var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.18.1.min'}}) || require;\r\n",
|
||
|
|
" fsharpPlotlyRequire(['plotly'], function(Plotly) {\r\n",
|
||
|
|
" var data = [{\"type\":\"scatter\",\"name\":\"Fast MA\",\"mode\":\"lines\",\"x\":[\"2022-01-31T14:30:00\",\"2022-02-01T14:30:00\",\"2022-02-02T14:30:00\",\"2022-02-03T14:30:00\",\"2022-02-04T14:30:00\",\"2022-02-07T14:30:00\",\"2022-02-08T14:30:00\",\"2022-02-09T14:30:00\",\"2022-02-10T14:30:00\",\"2022-02-11T14:30:00\",\"2022-02-14T14:30:00\",\"2022-02-15T14:30:00\",\"2022-02-16T14:30:00\",\"2022-02-17T14:30:00\",\"2022-02-18T14:30:00\",\"2022-02-22T14:30:00\",\"2022-02-23T14:30:00\",\"2022-02-24T14:30:00\",\"2022-02-25T14:30:00\",\"2022-02-28T14:30:00\",\"2022-03-01T14:30:00\",\"2022-03-02T14:30:00\",\"2022-03-03T14:30:00\",\"2022-03-04T14:30:00\",\"2022-03-07T14:30:00\",\"2022-03-08T14:30:00\",\"2022-03-09T14:30:00\",\"2022-03-10T14:30:00\",\"2022-03-11T14:30:00\",\"2022-03-14T13:30:00\",\"2022-03-15T13:30:00\",\"2022-03-16T13:30:00\",\"2022-03-17T13:30:00\",\"2022-03-18T13:30:00\",\"2022-03-21T13:30:00\",\"2022-03-22T13:30:00\",\"2022-03-23T13:30:00\",\"2022-03-24T13:30:00\",\"2022-03-25T13:30:00\",\"2022-03-28T13:30:00\",\"2022-03-29T13:30:00\",\"2022-03-30T13:30:00\",\"2022-03-31T13:30:00\",\"2022-04-01T13:30:00\",\"2022-04-04T13:30:00\",\"2022-04-05T13:30:00\",\"2022-04-06T13:30:00\",\"2022-04-07T13:30:00\",\"2022-04-08T13:30:00\",\"2022-04-11T13:30:00\",\"2022-04-12T13:30:00\",\"2022-04-13T13:30:00\",\"2022-04-14T13:30:00\",\"2022-04-18T13:30:00\",\"2022-04-19T13:30:00\",\"2022-04-20T13:30:00\",\"2022-04-21T13:30:00\",\"2022-04-22T13:30:00\",\"2022-04-25T13:30:00\",\"2022-04-26T13:30:00\",\"2022-04-27T13:30:00\",\"2022-04-28T13:30:00\",\"2022-04-29T13:30:00\",\"2022-05-02T13:30:00\",\"2022-05-03T13:30:00\",\"2022-05-04T13:30:00\",\"2022-05-05T13:30:00\",\"2022-05-06T13:30:00\",\"2022-05-09T13:30:00\",\"2022-05-10T13:30:00\",\"2022-05-11T13:30:00\",\"2022-05-12T13:30:00\",\"2022-05-13T13:30:00\",\"2022-05-16T13:30:00\",\"2022-05-17T13:30:00\",\"2022-05-18T13:30:00\",\"2022-05-19T13:30:00\",\"2022-05-20T13:30:00\",\"2022-05-23T13:30:00\",\"2022-05-24T13:30:00\",\"2022-05-25T13:30:00\",\"2022-05-26T13:30:00\",\"2022-05-27T13:30:00\",\"2022-05-31T13:30:00\",\"2022-06-01T13:30:00\",\"2022-06-02T13:30:00\",\"2022-06-03T13:30:00\",\"2022-06-06T13:30:00\",\"2022-06-07T13:30:00\",\"2022-06-08T13:30:00\",\"2022-06-09T13:30:00\",\"2022-06-10T13:30:00\",\"2022-06-13T13:30:00\",\"2022-06-14T13:30:00\",\"2022-06-15T13:30:00\",\"2022-06-16T13:30:00\",\"2022-06-17T13:30:00\",\"2022-06-21T13:30:00\",\"2022-06-22T13:30:00\",\"2022-06-23T13:30:00\",\"2022-06-24T13:30:00\",\"2022-06-27T13:30:00\",\"2022-06-28T13:30:00\",\"2022-06-29T13:30:00\",\"2022-06-30T13:30:00\",\"2022-07-01T13:30:00\",\"2022-07-05T13:30:00\",\"2022-07-06T13:30:00\",\"2022-07-07T13:30:00\",\"2022-07-08T13:30:00\",\"2022-07-11T13:30:00\",\"2022-07-12T13:30:00\",\"2022-07-13T13:30:00\",\"2022-07-14T13:30:00\",\"2022-07-15T13:30:00\",\"2022-07-18T13:30:00\",\"2022-07-19T13:30:00\",\"2022-07-20T13:30:00\",\"2022-07-21T13:30:00\",\"2022-07-22T13:30:00\",\"2022-07-25T13:30:00\",\"2022-07-26T13:30:00\",\"2022-07-27T13:30:00\",\"2022-07-28T13:30:00\",\"2022-07-29T13:30:00\",\"2022-08-01T13:30:00\",\"2022-08-02T13:30:00\",\"2022-08-03T13:30:00\",\"2022-08-04T13:30:00\",\"2022-08-05T13:30:00\",\"2022-08-08T13:30:00\",\"2022-08-09T13:30:00\",\"2022-08-10T13:30:00\",\"2022-08-11T13:30:00\",\"2022-08-12T13:30:00\",\"2022-08-15T13:30:00\",\"2022-08-16T13:30:00\",\"2022-08-17T13:30:00\",\"2022-08-18T13:30:00\",\"2022-08-19T13:30:00\",\"2022-08-22T13:30:00\",\"2022-08-23T13:30:00\",\"2022-08-24T13:30:00\",\"2022-08-25T13:30:00\",\"2022-08-26T13:30:00\",\"2022-08-29T13:30:00\",\"2022-08-30T13:30:00\",\"2022-08-31T13:30:00\",\"2022-09-01T13:30:00\",\"2022-09-02T13:30:00\",\"2022-09-06T13:30:00\",\"2022-09-07T13:30:00\",\"2022-09-08T13:30:00\",\"2022-09-09T13:30:00\",\"2022-09-12T13:30:00\",\"2022-09-13T13:30:00\",\"2022-09-14T13:30:00\",\"2022-09-15T13:30:00\",\"2022-09-16T13:30:00\",\"2022-09-19T13:30:00\",\"2022-09-20T13:30:00\",\"2022-09-21T13:30:00\",\"2022-09-22T13:30:00\",\"2022-09-23T13:30:00\",\"2022-09-26T13:30:00\",\"2022-09-27T13:30:00\",\"2022-09-28T1
|
||
|
|
" var layout = {\"width\":1200,\"height\":400,\"template\":{\"layout\":{\"title\":{\"x\":0.05},\"font\":{\"color\":\"rgba(42, 63, 95, 1.0)\"},\"paper_bgcolor\":\"rgba(255, 255, 255, 1.0)\",\"plot_bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"autotypenumbers\":\"strict\",\"colorscale\":{\"diverging\":[[0.0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1.0,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0.0,\"ticks\":\"\"}},\"geo\":{\"showland\":true,\"landcolor\":\"rgba(229, 236, 246, 1.0)\",\"showlakes\":true,\"lakecolor\":\"rgba(255, 255, 255, 1.0)\",\"subunitcolor\":\"rgba(255, 255, 255, 1.0)\",\"bgcolor\":\"rgba(255, 255, 255, 1.0)\"},\"mapbox\":{\"style\":\"light\"},\"polar\":{\"bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"radialaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"},\"angularaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"yaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"zaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true}},\"ternary\":{\"aaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"baxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"caxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"bgcolor\":\"rgba(229, 236, 246, 1.0)\"},\"xaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"yaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"shapedefaults\":{\"line\":{\"color\":\"rgba(42, 63, 95, 1.0)\"}},\"colorway\":[\"rgba(99, 110, 250, 1.0)\",\"rgba(239, 85, 59, 1.0)\",\"rgba(0, 204, 150, 1.0)\",\"rgba(171, 99, 250, 1.0)\",\"rgba(255, 161, 90, 1.0)\",\"rgba(25, 211, 243, 1.0)\",\"rgba(255, 102, 146, 1.0)\",\"rgba(182, 232, 128, 1.0)\",\"rgba(255, 151, 255, 1.0)\",\"rgba(254, 203, 82, 1.0)\"]},\"data\":{\"bar\":[{\"marker\":{\"line\":{\"color\":\"rgba(229, 236, 246, 1.0)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"s
|
||
|
|
" var config = {\"responsive\":true};\r\n",
|
||
|
|
" Plotly.newPlot('b34d57f3-6c88-49a8-8a00-ad8f5b0c3552', data, layout, config);\r\n",
|
||
|
|
" });\r\n",
|
||
|
|
"};\r\n",
|
||
|
|
"if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {\r\n",
|
||
|
|
" var script = document.createElement(\"script\");\r\n",
|
||
|
|
" script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\");\r\n",
|
||
|
|
" script.onload = function(){\r\n",
|
||
|
|
" renderPlotly_b34d57f36c8849a88a00ad8f5b0c3552();\r\n",
|
||
|
|
" };\r\n",
|
||
|
|
" document.getElementsByTagName(\"head\")[0].appendChild(script);\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"else {\r\n",
|
||
|
|
" renderPlotly_b34d57f36c8849a88a00ad8f5b0c3552();\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"</script></div>"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"source": [
|
||
|
|
"JMA_Series fastMA = new(data,12); //typically MACD uses EMA(12), but let's try with superior JMA(12)\n",
|
||
|
|
"JMA_Series slowMA = new(data,26); //likewise, let's use JMA(26) instead of EMA(26)\n",
|
||
|
|
"\n",
|
||
|
|
"//make a chart\n",
|
||
|
|
"var cfast = Chart2D.Chart.Line<DateTime,double,bool>(fastMA.t.Skip(warmup).ToList(), fastMA.v.Skip(warmup).ToList(), false, \"Fast MA\").WithLineStyle(Width: 2, Color: Color.fromString(\"blue\"));\n",
|
||
|
|
"var cslow = Chart2D.Chart.Line<DateTime,double,bool>(slowMA.t.Skip(warmup).ToList(), slowMA.v.Skip(warmup).ToList(), false, \"Slow MA\").WithLineStyle(Width: 2, Color: Color.fromString(\"red\"));\n",
|
||
|
|
"var chart = Chart.Combine(new []{cfast,cslow}).WithSize(1200,400).WithMargin(Margin.init<int, int, int, int, int, bool>(30,10,40,30,1,false))\n",
|
||
|
|
" .WithXAxisRangeSlider(RangeSlider.init(Visible:false)).WithTitle($\"slow MA and fast MA of {symbol} OHLC4\");\n",
|
||
|
|
"chart"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 21,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
},
|
||
|
|
"polyglot_notebook": {
|
||
|
|
"kernelName": "csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"<div><div id=\"0151fe48-bd08-4507-afc2-4ede6bcf60b4\"><!-- Plotly chart will be drawn inside this DIV --></div><script type=\"text/javascript\">\r\n",
|
||
|
|
"var renderPlotly_0151fe48bd084507afc24ede6bcf60b4 = function() {\r\n",
|
||
|
|
" var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.18.1.min'}}) || require;\r\n",
|
||
|
|
" fsharpPlotlyRequire(['plotly'], function(Plotly) {\r\n",
|
||
|
|
" var data = [{\"type\":\"scatter\",\"name\":\"MACD\",\"mode\":\"lines\",\"x\":[\"2022-01-31T14:30:00\",\"2022-02-01T14:30:00\",\"2022-02-02T14:30:00\",\"2022-02-03T14:30:00\",\"2022-02-04T14:30:00\",\"2022-02-07T14:30:00\",\"2022-02-08T14:30:00\",\"2022-02-09T14:30:00\",\"2022-02-10T14:30:00\",\"2022-02-11T14:30:00\",\"2022-02-14T14:30:00\",\"2022-02-15T14:30:00\",\"2022-02-16T14:30:00\",\"2022-02-17T14:30:00\",\"2022-02-18T14:30:00\",\"2022-02-22T14:30:00\",\"2022-02-23T14:30:00\",\"2022-02-24T14:30:00\",\"2022-02-25T14:30:00\",\"2022-02-28T14:30:00\",\"2022-03-01T14:30:00\",\"2022-03-02T14:30:00\",\"2022-03-03T14:30:00\",\"2022-03-04T14:30:00\",\"2022-03-07T14:30:00\",\"2022-03-08T14:30:00\",\"2022-03-09T14:30:00\",\"2022-03-10T14:30:00\",\"2022-03-11T14:30:00\",\"2022-03-14T13:30:00\",\"2022-03-15T13:30:00\",\"2022-03-16T13:30:00\",\"2022-03-17T13:30:00\",\"2022-03-18T13:30:00\",\"2022-03-21T13:30:00\",\"2022-03-22T13:30:00\",\"2022-03-23T13:30:00\",\"2022-03-24T13:30:00\",\"2022-03-25T13:30:00\",\"2022-03-28T13:30:00\",\"2022-03-29T13:30:00\",\"2022-03-30T13:30:00\",\"2022-03-31T13:30:00\",\"2022-04-01T13:30:00\",\"2022-04-04T13:30:00\",\"2022-04-05T13:30:00\",\"2022-04-06T13:30:00\",\"2022-04-07T13:30:00\",\"2022-04-08T13:30:00\",\"2022-04-11T13:30:00\",\"2022-04-12T13:30:00\",\"2022-04-13T13:30:00\",\"2022-04-14T13:30:00\",\"2022-04-18T13:30:00\",\"2022-04-19T13:30:00\",\"2022-04-20T13:30:00\",\"2022-04-21T13:30:00\",\"2022-04-22T13:30:00\",\"2022-04-25T13:30:00\",\"2022-04-26T13:30:00\",\"2022-04-27T13:30:00\",\"2022-04-28T13:30:00\",\"2022-04-29T13:30:00\",\"2022-05-02T13:30:00\",\"2022-05-03T13:30:00\",\"2022-05-04T13:30:00\",\"2022-05-05T13:30:00\",\"2022-05-06T13:30:00\",\"2022-05-09T13:30:00\",\"2022-05-10T13:30:00\",\"2022-05-11T13:30:00\",\"2022-05-12T13:30:00\",\"2022-05-13T13:30:00\",\"2022-05-16T13:30:00\",\"2022-05-17T13:30:00\",\"2022-05-18T13:30:00\",\"2022-05-19T13:30:00\",\"2022-05-20T13:30:00\",\"2022-05-23T13:30:00\",\"2022-05-24T13:30:00\",\"2022-05-25T13:30:00\",\"2022-05-26T13:30:00\",\"2022-05-27T13:30:00\",\"2022-05-31T13:30:00\",\"2022-06-01T13:30:00\",\"2022-06-02T13:30:00\",\"2022-06-03T13:30:00\",\"2022-06-06T13:30:00\",\"2022-06-07T13:30:00\",\"2022-06-08T13:30:00\",\"2022-06-09T13:30:00\",\"2022-06-10T13:30:00\",\"2022-06-13T13:30:00\",\"2022-06-14T13:30:00\",\"2022-06-15T13:30:00\",\"2022-06-16T13:30:00\",\"2022-06-17T13:30:00\",\"2022-06-21T13:30:00\",\"2022-06-22T13:30:00\",\"2022-06-23T13:30:00\",\"2022-06-24T13:30:00\",\"2022-06-27T13:30:00\",\"2022-06-28T13:30:00\",\"2022-06-29T13:30:00\",\"2022-06-30T13:30:00\",\"2022-07-01T13:30:00\",\"2022-07-05T13:30:00\",\"2022-07-06T13:30:00\",\"2022-07-07T13:30:00\",\"2022-07-08T13:30:00\",\"2022-07-11T13:30:00\",\"2022-07-12T13:30:00\",\"2022-07-13T13:30:00\",\"2022-07-14T13:30:00\",\"2022-07-15T13:30:00\",\"2022-07-18T13:30:00\",\"2022-07-19T13:30:00\",\"2022-07-20T13:30:00\",\"2022-07-21T13:30:00\",\"2022-07-22T13:30:00\",\"2022-07-25T13:30:00\",\"2022-07-26T13:30:00\",\"2022-07-27T13:30:00\",\"2022-07-28T13:30:00\",\"2022-07-29T13:30:00\",\"2022-08-01T13:30:00\",\"2022-08-02T13:30:00\",\"2022-08-03T13:30:00\",\"2022-08-04T13:30:00\",\"2022-08-05T13:30:00\",\"2022-08-08T13:30:00\",\"2022-08-09T13:30:00\",\"2022-08-10T13:30:00\",\"2022-08-11T13:30:00\",\"2022-08-12T13:30:00\",\"2022-08-15T13:30:00\",\"2022-08-16T13:30:00\",\"2022-08-17T13:30:00\",\"2022-08-18T13:30:00\",\"2022-08-19T13:30:00\",\"2022-08-22T13:30:00\",\"2022-08-23T13:30:00\",\"2022-08-24T13:30:00\",\"2022-08-25T13:30:00\",\"2022-08-26T13:30:00\",\"2022-08-29T13:30:00\",\"2022-08-30T13:30:00\",\"2022-08-31T13:30:00\",\"2022-09-01T13:30:00\",\"2022-09-02T13:30:00\",\"2022-09-06T13:30:00\",\"2022-09-07T13:30:00\",\"2022-09-08T13:30:00\",\"2022-09-09T13:30:00\",\"2022-09-12T13:30:00\",\"2022-09-13T13:30:00\",\"2022-09-14T13:30:00\",\"2022-09-15T13:30:00\",\"2022-09-16T13:30:00\",\"2022-09-19T13:30:00\",\"2022-09-20T13:30:00\",\"2022-09-21T13:30:00\",\"2022-09-22T13:30:00\",\"2022-09-23T13:30:00\",\"2022-09-26T13:30:00\",\"2022-09-27T13:30:00\",\"2022-09-28T13:3
|
||
|
|
" var layout = {\"width\":1200,\"height\":400,\"template\":{\"layout\":{\"title\":{\"x\":0.05},\"font\":{\"color\":\"rgba(42, 63, 95, 1.0)\"},\"paper_bgcolor\":\"rgba(255, 255, 255, 1.0)\",\"plot_bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"autotypenumbers\":\"strict\",\"colorscale\":{\"diverging\":[[0.0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1.0,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0.0,\"ticks\":\"\"}},\"geo\":{\"showland\":true,\"landcolor\":\"rgba(229, 236, 246, 1.0)\",\"showlakes\":true,\"lakecolor\":\"rgba(255, 255, 255, 1.0)\",\"subunitcolor\":\"rgba(255, 255, 255, 1.0)\",\"bgcolor\":\"rgba(255, 255, 255, 1.0)\"},\"mapbox\":{\"style\":\"light\"},\"polar\":{\"bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"radialaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"},\"angularaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"yaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"zaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true}},\"ternary\":{\"aaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"baxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"caxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"bgcolor\":\"rgba(229, 236, 246, 1.0)\"},\"xaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"yaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"shapedefaults\":{\"line\":{\"color\":\"rgba(42, 63, 95, 1.0)\"}},\"colorway\":[\"rgba(99, 110, 250, 1.0)\",\"rgba(239, 85, 59, 1.0)\",\"rgba(0, 204, 150, 1.0)\",\"rgba(171, 99, 250, 1.0)\",\"rgba(255, 161, 90, 1.0)\",\"rgba(25, 211, 243, 1.0)\",\"rgba(255, 102, 146, 1.0)\",\"rgba(182, 232, 128, 1.0)\",\"rgba(255, 151, 255, 1.0)\",\"rgba(254, 203, 82, 1.0)\"]},\"data\":{\"bar\":[{\"marker\":{\"line\":{\"color\":\"rgba(229, 236, 246, 1.0)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"s
|
||
|
|
" var config = {\"responsive\":true};\r\n",
|
||
|
|
" Plotly.newPlot('0151fe48-bd08-4507-afc2-4ede6bcf60b4', data, layout, config);\r\n",
|
||
|
|
" });\r\n",
|
||
|
|
"};\r\n",
|
||
|
|
"if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {\r\n",
|
||
|
|
" var script = document.createElement(\"script\");\r\n",
|
||
|
|
" script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\");\r\n",
|
||
|
|
" script.onload = function(){\r\n",
|
||
|
|
" renderPlotly_0151fe48bd084507afc24ede6bcf60b4();\r\n",
|
||
|
|
" };\r\n",
|
||
|
|
" document.getElementsByTagName(\"head\")[0].appendChild(script);\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"else {\r\n",
|
||
|
|
" renderPlotly_0151fe48bd084507afc24ede6bcf60b4();\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"</script></div>"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"source": [
|
||
|
|
"SUB_Series MACD_line = new(fastMA, slowMA); //MACD line is just a SUBtraction fastMA-slowMA\n",
|
||
|
|
"JMA_Series signal_line = new(MACD_line, 9); //signal line is an EMA(9) of MACD; we use superior JMA(9) instead\n",
|
||
|
|
"\n",
|
||
|
|
"//make a chart\n",
|
||
|
|
"var cfast = Chart2D.Chart.Line<DateTime,double,bool>(MACD_line.t.Skip(warmup).ToList(), MACD_line.v.Skip(warmup).ToList(), false, \"MACD\").WithLineStyle(Width: 2, Color: Color.fromString(\"orange\"));\n",
|
||
|
|
"var cslow = Chart2D.Chart.Line<DateTime,double,bool>(signal_line.t.Skip(warmup).ToList(), signal_line.v.Skip(warmup).ToList(), false, \"signal\").WithLineStyle(Width: 2, Color: Color.fromString(\"green\"));\n",
|
||
|
|
"var chart = Chart.Combine(new []{cfast,cslow}).WithSize(1200,400).WithMargin(Margin.init<int, int, int, int, int, bool>(30,10,40,30,1,false))\n",
|
||
|
|
" .WithXAxisRangeSlider(RangeSlider.init(Visible:false)).WithTitle($\"MACD line and signal line of fastMA-slowMA\");\n",
|
||
|
|
"chart"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 22,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
},
|
||
|
|
"polyglot_notebook": {
|
||
|
|
"kernelName": "csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"<div><div id=\"51c93107-3183-4bc2-b4cf-998c40fe723a\"><!-- Plotly chart will be drawn inside this DIV --></div><script type=\"text/javascript\">\r\n",
|
||
|
|
"var renderPlotly_51c9310731834bc2b4cf998c40fe723a = function() {\r\n",
|
||
|
|
" var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.18.1.min'}}) || require;\r\n",
|
||
|
|
" fsharpPlotlyRequire(['plotly'], function(Plotly) {\r\n",
|
||
|
|
" var data = [{\"type\":\"bar\",\"x\":[\"2022-01-31T14:30:00\",\"2022-02-01T14:30:00\",\"2022-02-02T14:30:00\",\"2022-02-03T14:30:00\",\"2022-02-04T14:30:00\",\"2022-02-07T14:30:00\",\"2022-02-08T14:30:00\",\"2022-02-09T14:30:00\",\"2022-02-10T14:30:00\",\"2022-02-11T14:30:00\",\"2022-02-14T14:30:00\",\"2022-02-15T14:30:00\",\"2022-02-16T14:30:00\",\"2022-02-17T14:30:00\",\"2022-02-18T14:30:00\",\"2022-02-22T14:30:00\",\"2022-02-23T14:30:00\",\"2022-02-24T14:30:00\",\"2022-02-25T14:30:00\",\"2022-02-28T14:30:00\",\"2022-03-01T14:30:00\",\"2022-03-02T14:30:00\",\"2022-03-03T14:30:00\",\"2022-03-04T14:30:00\",\"2022-03-07T14:30:00\",\"2022-03-08T14:30:00\",\"2022-03-09T14:30:00\",\"2022-03-10T14:30:00\",\"2022-03-11T14:30:00\",\"2022-03-14T13:30:00\",\"2022-03-15T13:30:00\",\"2022-03-16T13:30:00\",\"2022-03-17T13:30:00\",\"2022-03-18T13:30:00\",\"2022-03-21T13:30:00\",\"2022-03-22T13:30:00\",\"2022-03-23T13:30:00\",\"2022-03-24T13:30:00\",\"2022-03-25T13:30:00\",\"2022-03-28T13:30:00\",\"2022-03-29T13:30:00\",\"2022-03-30T13:30:00\",\"2022-03-31T13:30:00\",\"2022-04-01T13:30:00\",\"2022-04-04T13:30:00\",\"2022-04-05T13:30:00\",\"2022-04-06T13:30:00\",\"2022-04-07T13:30:00\",\"2022-04-08T13:30:00\",\"2022-04-11T13:30:00\",\"2022-04-12T13:30:00\",\"2022-04-13T13:30:00\",\"2022-04-14T13:30:00\",\"2022-04-18T13:30:00\",\"2022-04-19T13:30:00\",\"2022-04-20T13:30:00\",\"2022-04-21T13:30:00\",\"2022-04-22T13:30:00\",\"2022-04-25T13:30:00\",\"2022-04-26T13:30:00\",\"2022-04-27T13:30:00\",\"2022-04-28T13:30:00\",\"2022-04-29T13:30:00\",\"2022-05-02T13:30:00\",\"2022-05-03T13:30:00\",\"2022-05-04T13:30:00\",\"2022-05-05T13:30:00\",\"2022-05-06T13:30:00\",\"2022-05-09T13:30:00\",\"2022-05-10T13:30:00\",\"2022-05-11T13:30:00\",\"2022-05-12T13:30:00\",\"2022-05-13T13:30:00\",\"2022-05-16T13:30:00\",\"2022-05-17T13:30:00\",\"2022-05-18T13:30:00\",\"2022-05-19T13:30:00\",\"2022-05-20T13:30:00\",\"2022-05-23T13:30:00\",\"2022-05-24T13:30:00\",\"2022-05-25T13:30:00\",\"2022-05-26T13:30:00\",\"2022-05-27T13:30:00\",\"2022-05-31T13:30:00\",\"2022-06-01T13:30:00\",\"2022-06-02T13:30:00\",\"2022-06-03T13:30:00\",\"2022-06-06T13:30:00\",\"2022-06-07T13:30:00\",\"2022-06-08T13:30:00\",\"2022-06-09T13:30:00\",\"2022-06-10T13:30:00\",\"2022-06-13T13:30:00\",\"2022-06-14T13:30:00\",\"2022-06-15T13:30:00\",\"2022-06-16T13:30:00\",\"2022-06-17T13:30:00\",\"2022-06-21T13:30:00\",\"2022-06-22T13:30:00\",\"2022-06-23T13:30:00\",\"2022-06-24T13:30:00\",\"2022-06-27T13:30:00\",\"2022-06-28T13:30:00\",\"2022-06-29T13:30:00\",\"2022-06-30T13:30:00\",\"2022-07-01T13:30:00\",\"2022-07-05T13:30:00\",\"2022-07-06T13:30:00\",\"2022-07-07T13:30:00\",\"2022-07-08T13:30:00\",\"2022-07-11T13:30:00\",\"2022-07-12T13:30:00\",\"2022-07-13T13:30:00\",\"2022-07-14T13:30:00\",\"2022-07-15T13:30:00\",\"2022-07-18T13:30:00\",\"2022-07-19T13:30:00\",\"2022-07-20T13:30:00\",\"2022-07-21T13:30:00\",\"2022-07-22T13:30:00\",\"2022-07-25T13:30:00\",\"2022-07-26T13:30:00\",\"2022-07-27T13:30:00\",\"2022-07-28T13:30:00\",\"2022-07-29T13:30:00\",\"2022-08-01T13:30:00\",\"2022-08-02T13:30:00\",\"2022-08-03T13:30:00\",\"2022-08-04T13:30:00\",\"2022-08-05T13:30:00\",\"2022-08-08T13:30:00\",\"2022-08-09T13:30:00\",\"2022-08-10T13:30:00\",\"2022-08-11T13:30:00\",\"2022-08-12T13:30:00\",\"2022-08-15T13:30:00\",\"2022-08-16T13:30:00\",\"2022-08-17T13:30:00\",\"2022-08-18T13:30:00\",\"2022-08-19T13:30:00\",\"2022-08-22T13:30:00\",\"2022-08-23T13:30:00\",\"2022-08-24T13:30:00\",\"2022-08-25T13:30:00\",\"2022-08-26T13:30:00\",\"2022-08-29T13:30:00\",\"2022-08-30T13:30:00\",\"2022-08-31T13:30:00\",\"2022-09-01T13:30:00\",\"2022-09-02T13:30:00\",\"2022-09-06T13:30:00\",\"2022-09-07T13:30:00\",\"2022-09-08T13:30:00\",\"2022-09-09T13:30:00\",\"2022-09-12T13:30:00\",\"2022-09-13T13:30:00\",\"2022-09-14T13:30:00\",\"2022-09-15T13:30:00\",\"2022-09-16T13:30:00\",\"2022-09-19T13:30:00\",\"2022-09-20T13:30:00\",\"2022-09-21T13:30:00\",\"2022-09-22T13:30:00\",\"2022-09-23T13:30:00\",\"2022-09-26T13:30:00\",\"2022-09-27T13:30:00\",\"2022-09-28T13:30:00\",\"2022-09-29T13:30:00\",\"2022-09-
|
||
|
|
" var layout = {\"width\":1200,\"height\":400,\"template\":{\"layout\":{\"title\":{\"x\":0.05},\"font\":{\"color\":\"rgba(42, 63, 95, 1.0)\"},\"paper_bgcolor\":\"rgba(255, 255, 255, 1.0)\",\"plot_bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"autotypenumbers\":\"strict\",\"colorscale\":{\"diverging\":[[0.0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1.0,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0.0,\"ticks\":\"\"}},\"geo\":{\"showland\":true,\"landcolor\":\"rgba(229, 236, 246, 1.0)\",\"showlakes\":true,\"lakecolor\":\"rgba(255, 255, 255, 1.0)\",\"subunitcolor\":\"rgba(255, 255, 255, 1.0)\",\"bgcolor\":\"rgba(255, 255, 255, 1.0)\"},\"mapbox\":{\"style\":\"light\"},\"polar\":{\"bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"radialaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"},\"angularaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"yaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"zaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true}},\"ternary\":{\"aaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"baxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"caxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"bgcolor\":\"rgba(229, 236, 246, 1.0)\"},\"xaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"yaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"shapedefaults\":{\"line\":{\"color\":\"rgba(42, 63, 95, 1.0)\"}},\"colorway\":[\"rgba(99, 110, 250, 1.0)\",\"rgba(239, 85, 59, 1.0)\",\"rgba(0, 204, 150, 1.0)\",\"rgba(171, 99, 250, 1.0)\",\"rgba(255, 161, 90, 1.0)\",\"rgba(25, 211, 243, 1.0)\",\"rgba(255, 102, 146, 1.0)\",\"rgba(182, 232, 128, 1.0)\",\"rgba(255, 151, 255, 1.0)\",\"rgba(254, 203, 82, 1.0)\"]},\"data\":{\"bar\":[{\"marker\":{\"line\":{\"color\":\"rgba(229, 236, 246, 1.0)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"s
|
||
|
|
" var config = {\"responsive\":true};\r\n",
|
||
|
|
" Plotly.newPlot('51c93107-3183-4bc2-b4cf-998c40fe723a', data, layout, config);\r\n",
|
||
|
|
" });\r\n",
|
||
|
|
"};\r\n",
|
||
|
|
"if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {\r\n",
|
||
|
|
" var script = document.createElement(\"script\");\r\n",
|
||
|
|
" script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\");\r\n",
|
||
|
|
" script.onload = function(){\r\n",
|
||
|
|
" renderPlotly_51c9310731834bc2b4cf998c40fe723a();\r\n",
|
||
|
|
" };\r\n",
|
||
|
|
" document.getElementsByTagName(\"head\")[0].appendChild(script);\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"else {\r\n",
|
||
|
|
" renderPlotly_51c9310731834bc2b4cf998c40fe723a();\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"</script></div>"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"source": [
|
||
|
|
"SUB_Series histogram = new(MACD_line, signal_line); //MACD histogram is an oscillator of MACD-signal\n",
|
||
|
|
"\n",
|
||
|
|
"//make a chart\n",
|
||
|
|
"var cfast = Chart2D.Chart.Column<double, DateTime, bool,bool,bool>(values: histogram.v.Skip(warmup).ToList(), Keys: histogram.t.Skip(warmup).ToList())\n",
|
||
|
|
".WithSize(1200,400).WithMargin(Margin.init<int, int, int, int, int, bool>(30,10,40,30,1,false)).WithXAxisRangeSlider(RangeSlider.init(Visible:false))\n",
|
||
|
|
".WithTitle(\"MACD histogram of MACD-signal\");\n",
|
||
|
|
"cfast"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 23,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
},
|
||
|
|
"polyglot_notebook": {
|
||
|
|
"kernelName": "csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"<div><div id=\"d92aa1a2-d3cb-4755-bda7-c135b9bacffb\"><!-- Plotly chart will be drawn inside this DIV --></div><script type=\"text/javascript\">\r\n",
|
||
|
|
"var renderPlotly_d92aa1a2d3cb4755bda7c135b9bacffb = function() {\r\n",
|
||
|
|
" var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.18.1.min'}}) || require;\r\n",
|
||
|
|
" fsharpPlotlyRequire(['plotly'], function(Plotly) {\r\n",
|
||
|
|
" var data = [{\"type\":\"scatter\",\"name\":\"state\",\"mode\":\"lines\",\"x\":[\"2022-01-31T14:30:00\",\"2022-02-01T14:30:00\",\"2022-02-02T14:30:00\",\"2022-02-03T14:30:00\",\"2022-02-04T14:30:00\",\"2022-02-07T14:30:00\",\"2022-02-08T14:30:00\",\"2022-02-09T14:30:00\",\"2022-02-10T14:30:00\",\"2022-02-11T14:30:00\",\"2022-02-14T14:30:00\",\"2022-02-15T14:30:00\",\"2022-02-16T14:30:00\",\"2022-02-17T14:30:00\",\"2022-02-18T14:30:00\",\"2022-02-22T14:30:00\",\"2022-02-23T14:30:00\",\"2022-02-24T14:30:00\",\"2022-02-25T14:30:00\",\"2022-02-28T14:30:00\",\"2022-03-01T14:30:00\",\"2022-03-02T14:30:00\",\"2022-03-03T14:30:00\",\"2022-03-04T14:30:00\",\"2022-03-07T14:30:00\",\"2022-03-08T14:30:00\",\"2022-03-09T14:30:00\",\"2022-03-10T14:30:00\",\"2022-03-11T14:30:00\",\"2022-03-14T13:30:00\",\"2022-03-15T13:30:00\",\"2022-03-16T13:30:00\",\"2022-03-17T13:30:00\",\"2022-03-18T13:30:00\",\"2022-03-21T13:30:00\",\"2022-03-22T13:30:00\",\"2022-03-23T13:30:00\",\"2022-03-24T13:30:00\",\"2022-03-25T13:30:00\",\"2022-03-28T13:30:00\",\"2022-03-29T13:30:00\",\"2022-03-30T13:30:00\",\"2022-03-31T13:30:00\",\"2022-04-01T13:30:00\",\"2022-04-04T13:30:00\",\"2022-04-05T13:30:00\",\"2022-04-06T13:30:00\",\"2022-04-07T13:30:00\",\"2022-04-08T13:30:00\",\"2022-04-11T13:30:00\",\"2022-04-12T13:30:00\",\"2022-04-13T13:30:00\",\"2022-04-14T13:30:00\",\"2022-04-18T13:30:00\",\"2022-04-19T13:30:00\",\"2022-04-20T13:30:00\",\"2022-04-21T13:30:00\",\"2022-04-22T13:30:00\",\"2022-04-25T13:30:00\",\"2022-04-26T13:30:00\",\"2022-04-27T13:30:00\",\"2022-04-28T13:30:00\",\"2022-04-29T13:30:00\",\"2022-05-02T13:30:00\",\"2022-05-03T13:30:00\",\"2022-05-04T13:30:00\",\"2022-05-05T13:30:00\",\"2022-05-06T13:30:00\",\"2022-05-09T13:30:00\",\"2022-05-10T13:30:00\",\"2022-05-11T13:30:00\",\"2022-05-12T13:30:00\",\"2022-05-13T13:30:00\",\"2022-05-16T13:30:00\",\"2022-05-17T13:30:00\",\"2022-05-18T13:30:00\",\"2022-05-19T13:30:00\",\"2022-05-20T13:30:00\",\"2022-05-23T13:30:00\",\"2022-05-24T13:30:00\",\"2022-05-25T13:30:00\",\"2022-05-26T13:30:00\",\"2022-05-27T13:30:00\",\"2022-05-31T13:30:00\",\"2022-06-01T13:30:00\",\"2022-06-02T13:30:00\",\"2022-06-03T13:30:00\",\"2022-06-06T13:30:00\",\"2022-06-07T13:30:00\",\"2022-06-08T13:30:00\",\"2022-06-09T13:30:00\",\"2022-06-10T13:30:00\",\"2022-06-13T13:30:00\",\"2022-06-14T13:30:00\",\"2022-06-15T13:30:00\",\"2022-06-16T13:30:00\",\"2022-06-17T13:30:00\",\"2022-06-21T13:30:00\",\"2022-06-22T13:30:00\",\"2022-06-23T13:30:00\",\"2022-06-24T13:30:00\",\"2022-06-27T13:30:00\",\"2022-06-28T13:30:00\",\"2022-06-29T13:30:00\",\"2022-06-30T13:30:00\",\"2022-07-01T13:30:00\",\"2022-07-05T13:30:00\",\"2022-07-06T13:30:00\",\"2022-07-07T13:30:00\",\"2022-07-08T13:30:00\",\"2022-07-11T13:30:00\",\"2022-07-12T13:30:00\",\"2022-07-13T13:30:00\",\"2022-07-14T13:30:00\",\"2022-07-15T13:30:00\",\"2022-07-18T13:30:00\",\"2022-07-19T13:30:00\",\"2022-07-20T13:30:00\",\"2022-07-21T13:30:00\",\"2022-07-22T13:30:00\",\"2022-07-25T13:30:00\",\"2022-07-26T13:30:00\",\"2022-07-27T13:30:00\",\"2022-07-28T13:30:00\",\"2022-07-29T13:30:00\",\"2022-08-01T13:30:00\",\"2022-08-02T13:30:00\",\"2022-08-03T13:30:00\",\"2022-08-04T13:30:00\",\"2022-08-05T13:30:00\",\"2022-08-08T13:30:00\",\"2022-08-09T13:30:00\",\"2022-08-10T13:30:00\",\"2022-08-11T13:30:00\",\"2022-08-12T13:30:00\",\"2022-08-15T13:30:00\",\"2022-08-16T13:30:00\",\"2022-08-17T13:30:00\",\"2022-08-18T13:30:00\",\"2022-08-19T13:30:00\",\"2022-08-22T13:30:00\",\"2022-08-23T13:30:00\",\"2022-08-24T13:30:00\",\"2022-08-25T13:30:00\",\"2022-08-26T13:30:00\",\"2022-08-29T13:30:00\",\"2022-08-30T13:30:00\",\"2022-08-31T13:30:00\",\"2022-09-01T13:30:00\",\"2022-09-02T13:30:00\",\"2022-09-06T13:30:00\",\"2022-09-07T13:30:00\",\"2022-09-08T13:30:00\",\"2022-09-09T13:30:00\",\"2022-09-12T13:30:00\",\"2022-09-13T13:30:00\",\"2022-09-14T13:30:00\",\"2022-09-15T13:30:00\",\"2022-09-16T13:30:00\",\"2022-09-19T13:30:00\",\"2022-09-20T13:30:00\",\"2022-09-21T13:30:00\",\"2022-09-22T13:30:00\",\"2022-09-23T13:30:00\",\"2022-09-26T13:30:00\",\"2022-09-27T13:30:00\",\"2022-09-28T13:
|
||
|
|
" var layout = {\"width\":1200,\"height\":400,\"template\":{\"layout\":{\"title\":{\"x\":0.05},\"font\":{\"color\":\"rgba(42, 63, 95, 1.0)\"},\"paper_bgcolor\":\"rgba(255, 255, 255, 1.0)\",\"plot_bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"autotypenumbers\":\"strict\",\"colorscale\":{\"diverging\":[[0.0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1.0,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0.0,\"ticks\":\"\"}},\"geo\":{\"showland\":true,\"landcolor\":\"rgba(229, 236, 246, 1.0)\",\"showlakes\":true,\"lakecolor\":\"rgba(255, 255, 255, 1.0)\",\"subunitcolor\":\"rgba(255, 255, 255, 1.0)\",\"bgcolor\":\"rgba(255, 255, 255, 1.0)\"},\"mapbox\":{\"style\":\"light\"},\"polar\":{\"bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"radialaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"},\"angularaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"yaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"zaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true}},\"ternary\":{\"aaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"baxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"caxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"bgcolor\":\"rgba(229, 236, 246, 1.0)\"},\"xaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"yaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"shapedefaults\":{\"line\":{\"color\":\"rgba(42, 63, 95, 1.0)\"}},\"colorway\":[\"rgba(99, 110, 250, 1.0)\",\"rgba(239, 85, 59, 1.0)\",\"rgba(0, 204, 150, 1.0)\",\"rgba(171, 99, 250, 1.0)\",\"rgba(255, 161, 90, 1.0)\",\"rgba(25, 211, 243, 1.0)\",\"rgba(255, 102, 146, 1.0)\",\"rgba(182, 232, 128, 1.0)\",\"rgba(255, 151, 255, 1.0)\",\"rgba(254, 203, 82, 1.0)\"]},\"data\":{\"bar\":[{\"marker\":{\"line\":{\"color\":\"rgba(229, 236, 246, 1.0)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"s
|
||
|
|
" var config = {\"responsive\":true};\r\n",
|
||
|
|
" Plotly.newPlot('d92aa1a2-d3cb-4755-bda7-c135b9bacffb', data, layout, config);\r\n",
|
||
|
|
" });\r\n",
|
||
|
|
"};\r\n",
|
||
|
|
"if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {\r\n",
|
||
|
|
" var script = document.createElement(\"script\");\r\n",
|
||
|
|
" script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\");\r\n",
|
||
|
|
" script.onload = function(){\r\n",
|
||
|
|
" renderPlotly_d92aa1a2d3cb4755bda7c135b9bacffb();\r\n",
|
||
|
|
" };\r\n",
|
||
|
|
" document.getElementsByTagName(\"head\")[0].appendChild(script);\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"else {\r\n",
|
||
|
|
" renderPlotly_d92aa1a2d3cb4755bda7c135b9bacffb();\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"</script></div>"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"source": [
|
||
|
|
"COMPARE_Series over = new(histogram,0); //generate over/under series when histogram is above/below zero\n",
|
||
|
|
"CROSS_Series trades = new(histogram,0); //generate a signal series where histogram crosses zero (from below and from above)\n",
|
||
|
|
"\n",
|
||
|
|
"//make a chart\n",
|
||
|
|
"var cover = Chart2D.Chart.Line<DateTime,double,bool>(over.t.Skip(warmup).ToList(),over.v.Skip(warmup).ToList(),false,\"state\").WithLineStyle(Width: 1, Color: Color.fromString(\"blue\"));\n",
|
||
|
|
"var cbars = Chart2D.Chart.Area<DateTime, double,bool>(trades.t.Skip(warmup).ToList(), trades.v.Skip(warmup).ToList(),false );\n",
|
||
|
|
"var chart = Chart.Combine(new []{cover,cbars}).WithSize(1200,400).WithMargin(Margin.init<int, int, int, int, int, bool>(30,10,40,30,1,false))\n",
|
||
|
|
" .WithXAxisRangeSlider(RangeSlider.init(Visible:false)).WithTitle(\"in-market signal and trading orders based on MACD histogram\");\n",
|
||
|
|
"chart"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 25,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
},
|
||
|
|
"polyglot_notebook": {
|
||
|
|
"kernelName": "csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"<div><div id=\"ea1f8a51-d55b-4122-ae43-264dbd1869b2\"><!-- Plotly chart will be drawn inside this DIV --></div><script type=\"text/javascript\">\r\n",
|
||
|
|
"var renderPlotly_ea1f8a51d55b4122ae43264dbd1869b2 = function() {\r\n",
|
||
|
|
" var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.18.1.min'}}) || require;\r\n",
|
||
|
|
" fsharpPlotlyRequire(['plotly'], function(Plotly) {\r\n",
|
||
|
|
" var data = [{\"type\":\"scatter\",\"mode\":\"lines\",\"x\":[\"2022-01-31T14:30:00\",\"2022-02-01T14:30:00\",\"2022-02-02T14:30:00\",\"2022-02-03T14:30:00\",\"2022-02-04T14:30:00\",\"2022-02-07T14:30:00\",\"2022-02-08T14:30:00\",\"2022-02-09T14:30:00\",\"2022-02-10T14:30:00\",\"2022-02-11T14:30:00\",\"2022-02-14T14:30:00\",\"2022-02-15T14:30:00\",\"2022-02-16T14:30:00\",\"2022-02-17T14:30:00\",\"2022-02-18T14:30:00\",\"2022-02-22T14:30:00\",\"2022-02-23T14:30:00\",\"2022-02-24T14:30:00\",\"2022-02-25T14:30:00\",\"2022-02-28T14:30:00\",\"2022-03-01T14:30:00\",\"2022-03-02T14:30:00\",\"2022-03-03T14:30:00\",\"2022-03-04T14:30:00\",\"2022-03-07T14:30:00\",\"2022-03-08T14:30:00\",\"2022-03-09T14:30:00\",\"2022-03-10T14:30:00\",\"2022-03-11T14:30:00\",\"2022-03-14T13:30:00\",\"2022-03-15T13:30:00\",\"2022-03-16T13:30:00\",\"2022-03-17T13:30:00\",\"2022-03-18T13:30:00\",\"2022-03-21T13:30:00\",\"2022-03-22T13:30:00\",\"2022-03-23T13:30:00\",\"2022-03-24T13:30:00\",\"2022-03-25T13:30:00\",\"2022-03-28T13:30:00\",\"2022-03-29T13:30:00\",\"2022-03-30T13:30:00\",\"2022-03-31T13:30:00\",\"2022-04-01T13:30:00\",\"2022-04-04T13:30:00\",\"2022-04-05T13:30:00\",\"2022-04-06T13:30:00\",\"2022-04-07T13:30:00\",\"2022-04-08T13:30:00\",\"2022-04-11T13:30:00\",\"2022-04-12T13:30:00\",\"2022-04-13T13:30:00\",\"2022-04-14T13:30:00\",\"2022-04-18T13:30:00\",\"2022-04-19T13:30:00\",\"2022-04-20T13:30:00\",\"2022-04-21T13:30:00\",\"2022-04-22T13:30:00\",\"2022-04-25T13:30:00\",\"2022-04-26T13:30:00\",\"2022-04-27T13:30:00\",\"2022-04-28T13:30:00\",\"2022-04-29T13:30:00\",\"2022-05-02T13:30:00\",\"2022-05-03T13:30:00\",\"2022-05-04T13:30:00\",\"2022-05-05T13:30:00\",\"2022-05-06T13:30:00\",\"2022-05-09T13:30:00\",\"2022-05-10T13:30:00\",\"2022-05-11T13:30:00\",\"2022-05-12T13:30:00\",\"2022-05-13T13:30:00\",\"2022-05-16T13:30:00\",\"2022-05-17T13:30:00\",\"2022-05-18T13:30:00\",\"2022-05-19T13:30:00\",\"2022-05-20T13:30:00\",\"2022-05-23T13:30:00\",\"2022-05-24T13:30:00\",\"2022-05-25T13:30:00\",\"2022-05-26T13:30:00\",\"2022-05-27T13:30:00\",\"2022-05-31T13:30:00\",\"2022-06-01T13:30:00\",\"2022-06-02T13:30:00\",\"2022-06-03T13:30:00\",\"2022-06-06T13:30:00\",\"2022-06-07T13:30:00\",\"2022-06-08T13:30:00\",\"2022-06-09T13:30:00\",\"2022-06-10T13:30:00\",\"2022-06-13T13:30:00\",\"2022-06-14T13:30:00\",\"2022-06-15T13:30:00\",\"2022-06-16T13:30:00\",\"2022-06-17T13:30:00\",\"2022-06-21T13:30:00\",\"2022-06-22T13:30:00\",\"2022-06-23T13:30:00\",\"2022-06-24T13:30:00\",\"2022-06-27T13:30:00\",\"2022-06-28T13:30:00\",\"2022-06-29T13:30:00\",\"2022-06-30T13:30:00\",\"2022-07-01T13:30:00\",\"2022-07-05T13:30:00\",\"2022-07-06T13:30:00\",\"2022-07-07T13:30:00\",\"2022-07-08T13:30:00\",\"2022-07-11T13:30:00\",\"2022-07-12T13:30:00\",\"2022-07-13T13:30:00\",\"2022-07-14T13:30:00\",\"2022-07-15T13:30:00\",\"2022-07-18T13:30:00\",\"2022-07-19T13:30:00\",\"2022-07-20T13:30:00\",\"2022-07-21T13:30:00\",\"2022-07-22T13:30:00\",\"2022-07-25T13:30:00\",\"2022-07-26T13:30:00\",\"2022-07-27T13:30:00\",\"2022-07-28T13:30:00\",\"2022-07-29T13:30:00\",\"2022-08-01T13:30:00\",\"2022-08-02T13:30:00\",\"2022-08-03T13:30:00\",\"2022-08-04T13:30:00\",\"2022-08-05T13:30:00\",\"2022-08-08T13:30:00\",\"2022-08-09T13:30:00\",\"2022-08-10T13:30:00\",\"2022-08-11T13:30:00\",\"2022-08-12T13:30:00\",\"2022-08-15T13:30:00\",\"2022-08-16T13:30:00\",\"2022-08-17T13:30:00\",\"2022-08-18T13:30:00\",\"2022-08-19T13:30:00\",\"2022-08-22T13:30:00\",\"2022-08-23T13:30:00\",\"2022-08-24T13:30:00\",\"2022-08-25T13:30:00\",\"2022-08-26T13:30:00\",\"2022-08-29T13:30:00\",\"2022-08-30T13:30:00\",\"2022-08-31T13:30:00\",\"2022-09-01T13:30:00\",\"2022-09-02T13:30:00\",\"2022-09-06T13:30:00\",\"2022-09-07T13:30:00\",\"2022-09-08T13:30:00\",\"2022-09-09T13:30:00\",\"2022-09-12T13:30:00\",\"2022-09-13T13:30:00\",\"2022-09-14T13:30:00\",\"2022-09-15T13:30:00\",\"2022-09-16T13:30:00\",\"2022-09-19T13:30:00\",\"2022-09-20T13:30:00\",\"2022-09-21T13:30:00\",\"2022-09-22T13:30:00\",\"2022-09-23T13:30:00\",\"2022-09-26T13:30:00\",\"2022-09-27T13:30:00\",\"2022-09-28T13:30:00\",\"2022-09-2
|
||
|
|
" var layout = {\"width\":1200,\"height\":400,\"template\":{\"layout\":{\"title\":{\"x\":0.05},\"font\":{\"color\":\"rgba(42, 63, 95, 1.0)\"},\"paper_bgcolor\":\"rgba(255, 255, 255, 1.0)\",\"plot_bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"autotypenumbers\":\"strict\",\"colorscale\":{\"diverging\":[[0.0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1.0,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0.0,\"ticks\":\"\"}},\"geo\":{\"showland\":true,\"landcolor\":\"rgba(229, 236, 246, 1.0)\",\"showlakes\":true,\"lakecolor\":\"rgba(255, 255, 255, 1.0)\",\"subunitcolor\":\"rgba(255, 255, 255, 1.0)\",\"bgcolor\":\"rgba(255, 255, 255, 1.0)\"},\"mapbox\":{\"style\":\"light\"},\"polar\":{\"bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"radialaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"},\"angularaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"yaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"zaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true}},\"ternary\":{\"aaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"baxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"caxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"bgcolor\":\"rgba(229, 236, 246, 1.0)\"},\"xaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"yaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":\"height+width+left+right+top+bottom\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"shapedefaults\":{\"line\":{\"color\":\"rgba(42, 63, 95, 1.0)\"}},\"colorway\":[\"rgba(99, 110, 250, 1.0)\",\"rgba(239, 85, 59, 1.0)\",\"rgba(0, 204, 150, 1.0)\",\"rgba(171, 99, 250, 1.0)\",\"rgba(255, 161, 90, 1.0)\",\"rgba(25, 211, 243, 1.0)\",\"rgba(255, 102, 146, 1.0)\",\"rgba(182, 232, 128, 1.0)\",\"rgba(255, 151, 255, 1.0)\",\"rgba(254, 203, 82, 1.0)\"]},\"data\":{\"bar\":[{\"marker\":{\"line\":{\"color\":\"rgba(229, 236, 246, 1.0)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"s
|
||
|
|
" var config = {\"responsive\":true};\r\n",
|
||
|
|
" Plotly.newPlot('ea1f8a51-d55b-4122-ae43-264dbd1869b2', data, layout, config);\r\n",
|
||
|
|
" });\r\n",
|
||
|
|
"};\r\n",
|
||
|
|
"if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {\r\n",
|
||
|
|
" var script = document.createElement(\"script\");\r\n",
|
||
|
|
" script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\");\r\n",
|
||
|
|
" script.onload = function(){\r\n",
|
||
|
|
" renderPlotly_ea1f8a51d55b4122ae43264dbd1869b2();\r\n",
|
||
|
|
" };\r\n",
|
||
|
|
" document.getElementsByTagName(\"head\")[0].appendChild(script);\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"else {\r\n",
|
||
|
|
" renderPlotly_ea1f8a51d55b4122ae43264dbd1869b2();\r\n",
|
||
|
|
"}\r\n",
|
||
|
|
"</script></div>"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"source": [
|
||
|
|
"EQUITY_Series folio = new(trades, data, Long:true, Short:false, Warmup:warmup); //generate equity curve from trades and \n",
|
||
|
|
"\n",
|
||
|
|
"//make a chart\n",
|
||
|
|
"var cbars = Chart2D.Chart.Area<DateTime, double,bool>(folio.t.Skip(warmup).ToList(), folio.v.Skip(warmup).ToList(),false ).WithSize(1200,400).WithMargin(Margin.init<int, int, int, int, int, bool>(30,10,40,30,1,false))\n",
|
||
|
|
" .WithXAxisRangeSlider(RangeSlider.init(Visible:false)).WithTitle($\"Trading P&L (long only) for MACD-generated trades on {symbol}\");\n",
|
||
|
|
"cbars"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"metadata": {
|
||
|
|
"kernelspec": {
|
||
|
|
"display_name": ".NET (C#)",
|
||
|
|
"language": "C#",
|
||
|
|
"name": ".net-csharp"
|
||
|
|
},
|
||
|
|
"language_info": {
|
||
|
|
"name": "polyglot-notebook"
|
||
|
|
},
|
||
|
|
"polyglot_notebook": {
|
||
|
|
"kernelInfo": {
|
||
|
|
"defaultKernelName": "csharp",
|
||
|
|
"items": [
|
||
|
|
{
|
||
|
|
"aliases": [
|
||
|
|
"C#",
|
||
|
|
"c#"
|
||
|
|
],
|
||
|
|
"languageName": "C#",
|
||
|
|
"name": "csharp"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"aliases": [
|
||
|
|
"frontend"
|
||
|
|
],
|
||
|
|
"name": "vscode"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"nbformat": 4,
|
||
|
|
"nbformat_minor": 2
|
||
|
|
}
|