This commit is contained in:
Miha
2022-04-19 15:46:34 -07:00
commit 50ed6f6504
120 changed files with 16787 additions and 0 deletions
+114
View File
@@ -0,0 +1,114 @@
// ADD - adding TSeries+TSeries together, or TSeries+double, or double+TSeries
using System;
namespace QuantLib;
public class ADD_Series : TSeries
{
readonly TSeries _d1;
readonly TSeries _d2;
readonly double _dd;
readonly byte _type;
public ADD_Series(TSeries d1, TSeries d2)
{
this._d1 = d1;
this._d2 = d2;
this._dd = 0;
this._type = 1;
d1.Pub += this.Sub;
d2.Pub += this.Sub;
if (d1.Count > 0 && d2.Count > 0)
{
for (int i = 0; i < Math.Min(d1.Count, d2.Count); i++)
{
this.Add(d1[i], d2[i], false);
}
}
}
public ADD_Series(TSeries d1, double dd)
{
this._d1 = d1;
this._d2 = null;
this._dd = dd;
this._type = 2;
d1.Pub += this.Sub;
if (d1.Count > 0)
{
for (int i = 0; i < d1.Count; i++)
{
this.Add(d1[i], dd, false);
}
}
}
public ADD_Series(double dd, TSeries d1)
{
this._d1 = d1;
this._d2 = null;
this._dd = dd;
this._type = 3;
d1.Pub += this.Sub;
if (d1.Count > 0)
{
for (int i = 0; i < d1.Count; i++)
{
this.Add(d1[i], dd, false);
}
}
}
public void Add((System.DateTime t, double v) d1,
(System.DateTime t, double v) d2, bool update = false)
{
(System.DateTime t, double v) result =
((d1.t > d2.t) ? d1.t : d2.t, d1.v + d2.v);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add((System.DateTime t, double v) d1, double dd,
bool update = false)
{
(System.DateTime t, double v) result = (d1.t, d1.v + dd);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add(double dd, (System.DateTime t, double v) d1, bool update = false) => this.Add(d1, dd, update);
public void Add(bool update = false)
{
if (update || (this._d1.Count > 0 && this._d1.Count == this._d2.Count &&
this.Count != this._d1.Count))
{
if (this._type == 1)
{
this.Add(this._d1[this._d1.Count - 1], this._d2[this._d2.Count - 1],
update);
}
else if (this._type == 2)
{
this.Add(this._d1[this._d1.Count - 1], this._dd, update);
}
else
{
this.Add(this._dd, this._d1[this._d1.Count - 1], update);
}
}
}
public new void Sub(object source, TSeriesEventArgs e) => this.Add(e.update);
}
+42
View File
@@ -0,0 +1,42 @@
namespace QuantLib;
using System;
public abstract class Single_TSeries_Indicator : TSeries
{
protected readonly int _p;
protected readonly bool _NaN;
protected readonly TSeries _data;
// Default Constructor
protected Single_TSeries_Indicator(TSeries source, int period, bool useNaN)
{
this._data = source;
this._p = period;
this._NaN = useNaN;
this._data.Pub += this.Sub;
}
// overridable Add() method for the whole series (should be replaced with faster algo than default)
public virtual void Add(TSeries data)
{
for (int i = 0; i < data.Count; i++)
{
this.Add(data[i], false);
}
}
// overridable Add() method to add/update a single value at the end of the list
public virtual new void Add((System.DateTime t, double v) tuple, bool update) => base.Add(tuple, update);
// Add() without update parameter assumes this is an insert of new data (update=false)
public new void Add((System.DateTime t, double v) d) => this.Add(d, update: false);
// Add() without a tuple assumes add/update using the last item in the source as new data
public void Add(bool update) => this.Add(this._data[this._data.Count - 1], update);
// Add() without any parameters assumes this is an insert of new data using the last item in the source
public void Add() => this.Add(this._data[this._data.Count - 1], update: false);
// When event is triggered, call Add(bool update)
public new void Sub(object source, TSeriesEventArgs e) => this.Add(this._data[this._data.Count - 1], e.update);
}
+125
View File
@@ -0,0 +1,125 @@
// DIV - divide TSeries/TSeries , or TSeries/double, or double/TSeries
using System;
namespace QuantLib;
public class DIV_Series : TSeries
{
readonly TSeries _d1, _d2;
readonly double _dd;
readonly byte _type;
public DIV_Series(TSeries d1, TSeries d2)
{
this._d1 = d1;
this._d2 = d2;
this._type = 1;
d1.Pub += this.Sub;
d2.Pub += this.Sub;
if (d1.Count > 0 && d2.Count > 0)
{
for (int i = 0; i < Math.Min(d1.Count, d2.Count); i++)
{
this.Add(d1[i], d2[i], false);
}
}
}
public DIV_Series(TSeries d1, double dd)
{
this._d1 = d1;
this._d2 = d1;
this._dd = dd;
this._type = 2;
d1.Pub += this.Sub;
if (d1.Count > 0)
{
for (int i = 0; i < d1.Count; i++)
{
this.Add(d1[i], dd, false);
}
}
}
public DIV_Series(double dd, TSeries d1)
{
this._d1 = d1;
this._d2 = d1;
this._dd = dd;
this._type = 3;
d1.Pub += this.Sub;
if (d1.Count > 0)
{
for (int i = 0; i < d1.Count; i++)
{
this.Add(dd, d1[i], false);
}
}
}
public void Add((System.DateTime t, double v) d1,
(System.DateTime t, double v) d2, bool update = false)
{
(System.DateTime t, double v) result =
((d1.t > d2.t) ? d1.t : d2.t,
(d2.v > double.Epsilon) ? d1.v / d2.v : double.PositiveInfinity);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add((System.DateTime t, double v) d1, double dd,
bool update = false)
{
(System.DateTime t, double v) result =
(d1.t, (dd > double.Epsilon) ? d1.v / dd : double.PositiveInfinity);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add(double dd, (System.DateTime t, double v) d1,
bool update = false)
{
(System.DateTime t, double v) result =
(d1.t, (d1.v > double.Epsilon) ? dd / d1.v : double.PositiveInfinity);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add(bool update = false)
{
if (update || (this._d1.Count > 0 && this._d1.Count == this._d2.Count &&
this.Count != this._d1.Count))
{
if (this._type == 1)
{
this.Add(this._d1[this._d1.Count - 1], this._d2[this._d2.Count - 1],
update);
}
else if (this._type == 2)
{
this.Add(this._d1[this._d1.Count - 1], this._dd, update);
}
else
{
this.Add(this._dd, this._d1[this._d1.Count - 1], update);
}
}
}
public new void Sub(object source, TSeriesEventArgs e) { this.Add(e.update); }
}
+55
View File
@@ -0,0 +1,55 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class BIAS_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 1;
#endregion Parameters
private readonly TBars bars = new();
///////
private BIAS_Series indicator;
///////
public BIAS_chart()
{
this.SeparateWindow = true;
this.Name = "BIAS - Rate of change";
this.Description = "Bias description";
this.AddLineSeries("BIAS", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"BIAS (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class DEMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private DEMA_Series indicator;
///////
public DEMA_chart()
{
this.SeparateWindow = false;
this.Name = "DEMA - Double Exponential Moving Average";
this.Description = "Double Exponential Moving Average description";
this.AddLineSeries("DEMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"DEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class EMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private EMA_Series indicator;
///////
public EMA_chart()
{
this.SeparateWindow = false;
this.Name = "EMA - Exponential Moving Average";
this.Description = "Exponential Moving Average description";
this.AddLineSeries("EMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"EMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class ENTP_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 5;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////
private ENTP_Series indicator;
///////
public ENTP_chart()
{
this.SeparateWindow = true;
this.Name = "ENTP - Entropy (Unpredictability)";
this.Description = "Entropy description";
this.AddLineSeries("ENTROPY", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"ENTP (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class HEMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private HEMA_Series indicator;
///////
public HEMA_chart()
{
this.SeparateWindow = false;
this.Name = "HEMA - Hull-EMA Moving Average";
this.Description = "Hull-EMA Moving Average description";
this.AddLineSeries("HEMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"HEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class HMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private HMA_Series indicator;
///////
public HMA_chart()
{
this.SeparateWindow = false;
this.Name = "HMA - Hull Moving Average";
this.Description = "Hull Moving Average description";
this.AddLineSeries("HMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"HMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class JMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private JMA_Series indicator;
///////
public JMA_chart()
{
this.SeparateWindow = false;
this.Name = "JMA - Jurik Moving Average";
this.Description = "Jurik Moving Average description";
this.AddLineSeries("JMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"JMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+55
View File
@@ -0,0 +1,55 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class KURT_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 40;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////
private KURT_Series indicator;
///////
public KURT_chart()
{
this.SeparateWindow = true;
this.Name = "KURT - Kurtosis (Flatness)";
this.Description = "Kurtosis description";
this.AddLineSeries("KURTOSIS", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"KURT (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class MAD_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////
private MAD_Series indicator;
///////
public MAD_chart()
{
this.SeparateWindow = true;
this.Name = "MAD - Mean Absolute Deviation";
this.Description = "MAD description";
this.AddLineSeries("MAD", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"MAD (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class MAPE_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////dotnet
private MAPE_Series indicator;
///////
public MAPE_chart()
{
this.SeparateWindow = true;
this.Name = "MAPE - Mean Absolute Percentage Error";
this.Description = "MAPE description";
this.AddLineSeries("MAPE", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"MAPE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class MAX_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 1;
#endregion Parameters
private readonly TBars bars = new();
///////
private MAX_Series indicator;
///////
public MAX_chart()
{
this.SeparateWindow = false;
this.Name = "MAX - Moving Maximum";
this.Description = "Moving Maximum description";
this.AddLineSeries("MAX", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"MAX (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+54
View File
@@ -0,0 +1,54 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class MED_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////
private MED_Series indicator;
///////
public MED_chart()
{
this.SeparateWindow = false;
this.Name = "MED - Moving Median";
this.Description = "Moving Median description";
this.AddLineSeries("MED", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"MED (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class MIN_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 2;
#endregion Parameters
private readonly TBars bars = new();
///////
private MIN_Series indicator;
///////
public MIN_chart()
{
this.SeparateWindow = false;
this.Name = "MIN - Moving Minimum";
this.Description = "Moving Minimum description";
this.AddLineSeries("MIN", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"MIN (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class MSE_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////
private MSE_Series indicator;
///////
public MSE_chart()
{
this.SeparateWindow = true;
this.Name = "MSE = Mean Square Error";
this.Description = "MSE description";
this.AddLineSeries("MSE", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"MSE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class PSDEV_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////dotnet
private PSDEV_Series indicator;
///////
public PSDEV_chart()
{
this.SeparateWindow = true;
this.Name = "PSDEV - Population Standard Deviation (Biased)";
this.Description = "PSDEV description";
this.AddLineSeries("PSDEV", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"PSDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class PVAR_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////dotnet
private PVAR_Series indicator;
///////
public PVAR_chart()
{
this.SeparateWindow = true;
this.Name = "PVAR - Population Variance (Biased)";
this.Description = "PVAR description";
this.AddLineSeries("PVAR", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"PVAR (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class RMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private RMA_Series indicator;
///////
public RMA_chart()
{
this.SeparateWindow = false;
this.Name = "RMA - WildeR Moving Average";
this.Description = "WildeR Moving Average description";
this.AddLineSeries("RMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"RMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class SDEV_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////dotnet
private SDEV_Series indicator;
///////
public SDEV_chart()
{
this.SeparateWindow = true;
this.Name = "SDEV - Sample Standard Deviation (Unbiased)";
this.Description = "SDEV description";
this.AddLineSeries("SDEV", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"SDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class SMAPE_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////dotnet
private SMAPE_Series indicator;
///////
public SMAPE_chart()
{
this.SeparateWindow = true;
this.Name = "SMAPE - Symmetric Mean Absolute Percentage Error";
this.Description = "SMAPE description";
this.AddLineSeries("SMAPE", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"SMAPE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class SMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private SMA_Series indicator;
///////
public SMA_chart()
{
this.SeparateWindow = false;
this.Name = "SMA - Simple Moving Average";
this.Description = "Simple Moving Average description";
this.AddLineSeries("SMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"SMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class TEMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private TEMA_Series indicator;
///////
public TEMA_chart()
{
this.SeparateWindow = false;
this.Name = "TEMA - Triple Exponential Moving Average";
this.Description = "Triple Exponential Moving Average description";
this.AddLineSeries("TEMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"TEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+57
View File
@@ -0,0 +1,57 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class VAR_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 8;
#endregion Parameters
private readonly TBars bars = new();
///////dotnet
private VAR_Series indicator;
///////
public VAR_chart()
{
this.SeparateWindow = true;
this.Name = "VAR - Sample Variance (Unbiased)";
this.Description = "VAR description";
this.AddLineSeries("VAR", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"VAR (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+68
View File
@@ -0,0 +1,68 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
public class WMAPE_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]{
"Open", 0,
"High", 1,
"Low", 2,
"Close", 3,
"HL2", 4,
"OC2", 5,
"OHL3", 6,
"HLC3", 7,
"OHLC4", 8,
"Weighted (HLCC4)", 9
})]
private int DataSource = 8;
#endregion Parameters
private readonly QuanTAlib.TBars bars = new();
///////dotnet
private QuanTAlib.WMAPE_Series indicator;
///////
public WMAPE_chart()
{
this.SeparateWindow = true;
this.Name = "WMAPE - Weighted Mean Absolute Percentage Error";
this.Description = "WMAPE description";
this.AddLineSeries("WMAPE", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName = "WMAPE (" + QuantLib.TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: true);
}
protected void OnNewData(bool update = false)
{
this.indicator.Add(update);
}
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar || args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open), this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low), this.GetPrice(PriceType.Close), this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class WMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private WMA_Series indicator;
///////
public WMA_chart()
{
this.SeparateWindow = false;
this.Name = "WMA - Weighted Moving Average";
this.Description = "Weighted Moving Average description";
this.AddLineSeries("WMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"WMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+56
View File
@@ -0,0 +1,56 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class ZLEMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private int DataSource = 3;
#endregion Parameters
private readonly TBars bars = new();
///////
private ZLEMA_Series indicator;
///////
public ZLEMA_chart()
{
this.SeparateWindow = false;
this.Name = "ZLEMA - Zero-lag Exponential Moving Average";
this.Description = "Zero-Lag Exponential Moving Average description";
this.AddLineSeries("ZLEMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.ShortName =
"ZLEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
protected void OnNewData(bool update = false) { this.indicator.Add(update); }
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
this.OnNewData(update);
double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result);
}
}
+117
View File
@@ -0,0 +1,117 @@
// MUL - multiply TSeries*TSeries together, or TSeries*double, or double*TSeries
using System;
namespace QuantLib;
public class MUL_Series : TSeries
{
readonly TSeries _d1, _d2;
readonly double _dd;
readonly byte _type;
public MUL_Series(TSeries d1, TSeries d2)
{
this._d1 = d1;
this._d2 = d2;
this._dd = 0;
this._type = 1;
d1.Pub += this.Sub;
d2.Pub += this.Sub;
if (d1.Count > 0 && d2.Count > 0)
{
for (int i = 0; i < Math.Min(d1.Count, d2.Count); i++)
{
this.Add(d1[i], d2[i], false);
}
}
}
public MUL_Series(TSeries d1, double dd)
{
this._d1 = d1;
this._d2 = d1;
this._dd = dd;
this._type = 2;
d1.Pub += this.Sub;
if (d1.Count > 0)
{
for (int i = 0; i < d1.Count; i++)
{
this.Add(d1[i], dd, false);
}
}
}
public MUL_Series(double dd, TSeries d1)
{
this._d1 = d1;
this._d2 = d1;
this._dd = dd;
this._type = 3;
d1.Pub += this.Sub;
if (d1.Count > 0)
{
for (int i = 0; i < d1.Count; i++)
{
this.Add(d1[i], dd, false);
}
}
}
public void Add((System.DateTime t, double v) d1,
(System.DateTime t, double v) d2, bool update = false)
{
(System.DateTime t, double v) result =
((d1.t > d2.t) ? d1.t : d2.t, d1.v * d2.v);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add((System.DateTime t, double v) d1, double dd,
bool update = false)
{
(System.DateTime t, double v) result = (d1.t, d1.v * dd);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add(double dd, (System.DateTime t, double v) d1,
bool update = false)
{
this.Add(d1, dd, update);
}
public void Add(bool update = false)
{
if (update || (this._d1.Count > 0 && this._d1.Count == this._d2.Count &&
this.Count != this._d1.Count))
{
if (this._type == 1)
{
this.Add(this._d1[this._d1.Count - 1], this._d2[this._d2.Count - 1],
update);
}
else if (this._type == 2)
{
this.Add(this._d1[this._d1.Count - 1], this._dd, update);
}
else
{
this.Add(this._dd, this._d1[this._d1.Count - 1], update);
}
}
}
public new void Sub(object source, TSeriesEventArgs e) { this.Add(e.update); }
}
+28
View File
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<LangVersion>latest</LangVersion>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<Platforms>AnyCPU</Platforms>
<AlgoType>Indicator</AlgoType>
<AssemblyName>Quantower_QTAlib</AssemblyName>
<RootNamespace>QuanTAlib</RootNamespace>
<Configurations>Release</Configurations>
<BaseOutputPath>bin\</BaseOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Source\**\*.cs" Exclude="..\Source\obj\**"/>
</ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="AfterBuild" >
<Copy SourceFiles=".\bin\$(Configuration)\net48\Quantower_QTAlib.dll" DestinationFolder="\Quantower\Settings\Scripts\Indicators\QuanTAlib" />
</Target>
<ItemGroup>
<Reference Include="TradingPlatform.BusinessLayer">
<HintPath>.\dll\TradingPlatform.BusinessLayer.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
+20
View File
@@ -0,0 +1,20 @@
using System;
using QuantLib;
public class RND_Feed : TBars
{
public RND_Feed(int days, double volatility = 0.05, double startvalue = 100.0)
{
Random rnd = new();
double c = startvalue;
for (int i = 0; i < days; i++)
{
double o = Math.Round(c + c * (volatility * 0.1 * rnd.NextDouble() - 0.005), 2);
double h = Math.Round(o + c * volatility * rnd.NextDouble(), 2);
double l = Math.Round(o - c * volatility * rnd.NextDouble(), 2);
c = Math.Round(l + (h - l) * rnd.NextDouble(), 2);
double v = Math.Round(1000 * rnd.NextDouble(), 2);
this.Add(DateTime.Today.AddDays(i - days), o, h, l, c, v);
}
}
}
+125
View File
@@ -0,0 +1,125 @@
// SUB - subtracting TSeries-TSeries, or TSeries-double, or double-TSeries
using System;
namespace QuantLib;
public class SUB_Series : TSeries
{
readonly TSeries _d1, _d2;
readonly double _dd;
readonly byte _type;
public SUB_Series(TSeries d1, TSeries d2)
{
this._d1 = d1;
this._d2 = d2;
this._dd = 0;
this._type = 1;
d1.Pub += this.Sub;
d2.Pub += this.Sub;
if (d1.Count > 0 && d2.Count > 0)
{
for (int i = 0; i < Math.Min(d1.Count, d2.Count); i++)
{
this.Add(d1[i], d2[i], false);
}
}
}
public SUB_Series(TSeries d1, double dd)
{
this._d1 = d1;
this._d2 = d1;
this._dd = dd;
this._type = 2;
d1.Pub += this.Sub;
if (d1.Count > 0)
{
for (int i = 0; i < d1.Count; i++)
{
this.Add(d1[i], dd, false);
}
}
}
public SUB_Series(double dd, TSeries d1)
{
this._d1 = d1;
this._d2 = d1;
this._dd = dd;
this._type = 3;
d1.Pub += this.Sub;
if (d1.Count > 0)
{
for (int i = 0; i < d1.Count; i++)
{
this.Add(dd, d1[i], false);
}
}
}
public void Add((System.DateTime t, double v) d1,
(System.DateTime t, double v) d2, bool update = false)
{
(System.DateTime t, double v) result =
((d1.t > d2.t) ? d1.t : d2.t, d1.v - d2.v);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add((System.DateTime t, double v) d1, double dd,
bool update = false)
{
(System.DateTime t, double v) result = (d1.t, d1.v - dd);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add(double dd, (System.DateTime t, double v) d1,
bool update = false)
{
(System.DateTime t, double v) result = (d1.t, dd - d1.v);
if (update)
{
base[base.Count - 1] = result;
}
else
{
base.Add(result);
}
}
public void Add(bool update = false)
{
if (update || (this._d1.Count > 0 && this._d1.Count == this._d2.Count &&
this.Count != this._d1.Count))
{
if (this._type == 1)
{
this.Add(this._d1[this._d1.Count - 1], this._d2[this._d2.Count - 1],
update);
}
else if (this._type == 2)
{
this.Add(this._d1[this._d1.Count - 1], this._dd, update);
}
else
{
this.Add(this._dd, this._d1[this._d1.Count - 1], update);
}
}
}
public new void Sub(object source, TSeriesEventArgs e) { this.Add(e.update); }
}
+104
View File
@@ -0,0 +1,104 @@
namespace QuantLib;
using System;
public class TBars : System.Collections.Generic.List<(DateTime t, double o, double h, double l, double c, double v)>
{
private readonly TSeries _open = new();
private readonly TSeries _high = new();
private readonly TSeries _low = new();
private readonly TSeries _close = new();
private readonly TSeries _volume = new();
private readonly TSeries _hl2 = new();
private readonly TSeries _oc2 = new();
private readonly TSeries _ohl3 = new();
private readonly TSeries _hlc3 = new();
private readonly TSeries _ohlc4 = new();
private readonly TSeries _hlcc4 = new();
public TSeries Open => this._open;
public TSeries High => this._high;
public TSeries Low => this._low;
public TSeries Close => this._close;
public TSeries Volume => this._volume;
public TSeries HL2 => this._hl2;
public TSeries OC2 => this._oc2;
public TSeries OHL3 => this._ohl3;
public TSeries HLC3 => this._hlc3;
public TSeries OHLC4 => this._ohlc4;
public TSeries HLCC4 => this._hlcc4;
public TSeries Select(int source)
{
return source switch
{
0 => _open,
1 => _high,
2 => _low,
3 => _close,
4 => _hl2,
5 => _oc2,
6 => _ohl3,
7 => _hlc3,
8 => _ohlc4,
_ => _hlcc4,
};
}
public static string SelectStr(int source)
{
return source switch
{
0 => "Open",
1 => "High",
2 => "Low",
3 => "Close",
4 => "HL2",
5 => "OC2",
6 => "OHL3",
7 => "Typical",
8 => "Mean",
_ => "Weighted",
};
}
public void
Add((DateTime t, double o, double h, double l, double c, double v) i, bool update = false)
=> Add(i.t, i.o, i.h, i.l, i.c, i.v, update);
public void Add(DateTime t, decimal o, decimal h, decimal l, decimal c, decimal v, bool update = false)
=> Add(t, (double)o, (double)h, (double)l, (double)c, (double)v, update);
public void Add(DateTime t, double o, double h, double l, double c, double v, bool update = false)
{
if (update)
{
this[this.Count - 1] = (t, o, h, l, c, v);
_open[_open.Count - 1] = (t, o);
_high[_high.Count - 1] = (t, h);
_low[_low.Count - 1] = (t, l);
_close[_close.Count - 1] = (t, c);
_volume[_volume.Count - 1] = (t, v);
_hl2[_hl2.Count - 1] = (t, (h + l) * 0.5);
_oc2[_oc2.Count - 1] = (t, (o + c) * 0.5);
_ohl3[_ohl3.Count - 1] = (t, (o + h + l) * 0.333333333333333);
_hlc3[_hlc3.Count - 1] = (t, (h + l + c) * 0.333333333333333);
_ohlc4[_ohlc4.Count - 1] = (t, (o + h + l + c) * 0.25);
_hlcc4[_hlcc4.Count - 1] = (t, (h + l + c + c) * 0.25);
}
else
{
base.Add((t, o, h, l, c, v));
_open.Add((t, o));
_high.Add((t, h));
_low.Add((t, l));
_close.Add((t, c));
_volume.Add((t, v));
_hl2.Add((t, (h + l) * 0.5));
_oc2.Add((t, (o + c) * 0.5));
_ohl3.Add((t, (o + h + l) * 0.333333333333333));
_hlc3.Add((t, (h + l + c) * 0.333333333333333));
_ohlc4.Add((t, (o + h + l + c) * 0.25));
_hlcc4.Add((t, (h + l + c + c) * 0.25));
}
}
}
+72
View File
@@ -0,0 +1,72 @@
namespace QuantLib;
using System;
using System.Linq;
public class TSeries : System.Collections.Generic.List<(DateTime t, double v)>
{
// when asked for a (t,v) tuple, return the last (t,v) on the List
public static implicit operator (DateTime t, double v)(TSeries l) => l[l.Count - 1];
// when asked for a (double), return the value part of the last tuple on the list
public static implicit operator double(TSeries l) => l[l.Count - 1].v;
// when asked for a (DateTime), return the DateTime part of the last tuple on the list
public static implicit operator DateTime(TSeries l) => l[l.Count - 1].t;
public System.Collections.Generic.List<DateTime> t =>
this.Select(x => (DateTime)x.t).ToList();
public System.Collections.Generic.List<double> v =>
this.Select(x => (double)x.v).ToList();
public int Length => this.Count;
// add/update one (t,v) tuple to/at the end of the list
public void Add((DateTime t, double v) TValue, bool update = false)
{
if (update) { this[this.Count - 1] = TValue; }
else { base.Add(TValue); }
this.OnEvent(update);
}
public void Add(DateTime t, double v, bool update = false) => this.Add((t, v), update);
public void Add(double v, bool update = false) => this.Add((DateTime.Now, v), update);
// Broadcast handler - only to valid targets
protected virtual void OnEvent(bool update = false)
{
if (Pub != null && Pub.Target != this)
{
Pub(this, new TSeriesEventArgs { update = update });
}
}
// delegate used by event handler + event handler (Pub == publisher)
public delegate
void NewDataEventHandler(object source, TSeriesEventArgs args);
public event NewDataEventHandler Pub;
public void Sub(object source, TSeriesEventArgs e)
{
TSeries ss = (TSeries)source;
if (ss.Count > 0)
{
for (int i = 0; i < ss.Count; i++)
{
this.Add(ss[i]);
}
}
else
{
this.Add(ss[ss.Count - 1], e.update);
}
}
}
// EventArgs extension - carries the update field
public class TSeriesEventArgs : EventArgs
{
public bool update { get; set; }
}
Binary file not shown.
File diff suppressed because it is too large Load Diff