mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-05 20:47:43 +00:00
Refactor COMPARE and CROSS classes, plus add xMA chart
This commit is contained in:
@@ -70,9 +70,9 @@ public class TBars : System.Collections.Generic.List<(DateTime t, double o, doub
|
||||
4 => "HL2",
|
||||
5 => "OC2",
|
||||
6 => "OHL3",
|
||||
7 => "Typical",
|
||||
8 => "Mean",
|
||||
_ => "Weighted",
|
||||
7 => "HLC3",
|
||||
8 => "OHLC4",
|
||||
_ => "HLCC4",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace QuanTAlib;
|
||||
using System;
|
||||
|
||||
/* <summary>
|
||||
COMPARE - Generates +1 if A is above B, -1 if A is below B and 0 if A=B
|
||||
|
||||
|
||||
</summary> */
|
||||
|
||||
public class COMPARE_Series : Pair_TSeries_Indicator {
|
||||
|
||||
public COMPARE_Series(TSeries d1, TSeries d2) : base(d1, d2) {
|
||||
if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
|
||||
}
|
||||
public COMPARE_Series(TSeries d1, double dd2) : base(d1, dd2) {
|
||||
if (base._d1.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } }
|
||||
}
|
||||
public COMPARE_Series(double dd1, TSeries d2) : base(dd1, d2) {
|
||||
if (base._d2.Count > 0) { for (int i = 0; i < base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } }
|
||||
}
|
||||
|
||||
public override void Add((System.DateTime t, double v) TValue1, (System.DateTime t, double v) TValue2, bool update) {
|
||||
|
||||
double val = TValue1.v > TValue2.v ? 1 : -1;
|
||||
val = TValue1.v == TValue2.v ? 0 : val;
|
||||
(System.DateTime t, double v) over = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t, TValue1.v > TValue2.v ? 1 : val);
|
||||
if (update) { base[^1] = over; }
|
||||
else { base.Add(over); }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,17 +9,17 @@ Remarks:
|
||||
|
||||
</summary> */
|
||||
|
||||
public class OVER_Series : Pair_TSeries_Indicator {
|
||||
public class CROSS_Series : Pair_TSeries_Indicator {
|
||||
public TSeries Cross { get; set; } = new();
|
||||
|
||||
private double _previous = double.NaN;
|
||||
public OVER_Series(TSeries d1, TSeries d2) : base(d1, d2) {
|
||||
public CROSS_Series(TSeries d1, TSeries d2) : base(d1, d2) {
|
||||
if (base._d1.Count > 0 && base._d2.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], base._d2[i], false); } }
|
||||
}
|
||||
public OVER_Series(TSeries d1, double dd2) : base(d1, dd2) {
|
||||
public CROSS_Series(TSeries d1, double dd2) : base(d1, dd2) {
|
||||
if (base._d1.Count > 0) { for (int i = 0; i < base._d1.Count; i++) { this.Add(base._d1[i], (base._d1[i].t, dd2), false); } }
|
||||
}
|
||||
public OVER_Series(double dd1, TSeries d2) : base(dd1, d2) {
|
||||
public CROSS_Series(double dd1, TSeries d2) : base(dd1, d2) {
|
||||
if (base._d2.Count > 0) { for (int i = 0; i < base._d2.Count; i++) { this.Add((base._d2[i].t, dd1), base._d2[i], false); } }
|
||||
}
|
||||
|
||||
@@ -27,15 +27,13 @@ public class OVER_Series : Pair_TSeries_Indicator {
|
||||
|
||||
double val = TValue1.v > TValue2.v ? 1 : -1;
|
||||
val = TValue1.v == TValue2.v ? 0 : val;
|
||||
(System.DateTime t, double v) over = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t, TValue1.v > TValue2.v ? 1 : val);
|
||||
if (update) { this.Cross[^1] = over; }
|
||||
else { this.Cross.Add(over); }
|
||||
double over = TValue1.v > TValue2.v ? 1 : val;
|
||||
|
||||
val = (this._previous < over.v) ? 1 : -1;
|
||||
val = (this._previous < over) ? 1 : -1;
|
||||
(System.DateTime t, double v) result = ((TValue1.t > TValue2.t) ? TValue1.t : TValue2.t,
|
||||
((this._previous == over.v) || Double.IsNaN(this._previous) || (this._previous == 0)) ? 0 : val);
|
||||
((this._previous == over) || Double.IsNaN(this._previous) || (this._previous == 0)) ? 0 : val);
|
||||
|
||||
this._previous = over.v;
|
||||
this._previous = over;
|
||||
|
||||
if (update) { base[^1] = result; }
|
||||
else { base.Add(result); }
|
||||
@@ -1,32 +0,0 @@
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class ATR_chart : QuanTAlib_Indicator {
|
||||
#region Parameters
|
||||
|
||||
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
|
||||
private readonly int Period = 10;
|
||||
|
||||
#endregion Parameters
|
||||
|
||||
private ATR_Series indicator;
|
||||
|
||||
public ATR_chart()
|
||||
{
|
||||
this.SeparateWindow = true;
|
||||
this.Name = "ATR - Average True Range";
|
||||
this.Description = "Average True Range description";
|
||||
this.AddLineSeries("ATR", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit() { base.OnInit();
|
||||
indicator = new(source: bars, period: Period, useNaN: false);
|
||||
}
|
||||
|
||||
protected override void OnUpdate(UpdateArgs args) {
|
||||
base.OnUpdate(args);
|
||||
this.SetValue(indicator[^1].v, lineIndex: 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class CCI_chart : Indicator
|
||||
{
|
||||
#region Parameters
|
||||
|
||||
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
|
||||
private readonly int Period = 10;
|
||||
|
||||
#endregion Parameters
|
||||
|
||||
private TBars bars;
|
||||
|
||||
///////
|
||||
private CCI_Series indicator;
|
||||
///////
|
||||
|
||||
public CCI_chart()
|
||||
{
|
||||
this.SeparateWindow = true;
|
||||
this.Name = "CCI - Commodity Channel Index";
|
||||
this.Description = "CCI description";
|
||||
this.AddLineSeries("CCI", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.bars = new();
|
||||
this.indicator = new(source: bars, period: this.Period, useNaN: false);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
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 TBars bars ;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: false);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class DJMA_chart : Indicator {
|
||||
#region Parameters
|
||||
|
||||
[InputParameter("Fast Data source", 0, 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 FDataSource = 3;
|
||||
|
||||
[InputParameter("Fast Smoothing period", 1, 1, 999, 1, 1)]
|
||||
private int FPeriod = 12;
|
||||
|
||||
[InputParameter("Fast Volatility short", 2, 3, 50, 1, 1)]
|
||||
private int FVshort = 10;
|
||||
|
||||
[InputParameter("Fast Volatility long", 3, 20, 500, 5, 1)]
|
||||
private int FVlong = 65;
|
||||
|
||||
[InputParameter("Fast Phase", 4, -100, 100, 1, 2)]
|
||||
private double FJphase = 100.0;
|
||||
|
||||
[InputParameter("Slow Data source", 5, 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 SDataSource = 3;
|
||||
|
||||
[InputParameter("Slow Smoothing period", 6, 1, 999, 1, 1)]
|
||||
private int SPeriod = 26;
|
||||
|
||||
[InputParameter("Slow Volatility short", 7, 3, 50, 1, 1)]
|
||||
private int SVshort = 10;
|
||||
|
||||
[InputParameter("Slow Volatility long", 8, 20, 500, 5, 1)]
|
||||
private int SVlong = 65;
|
||||
|
||||
[InputParameter("Slow Phase", 9, -100, 100, 1, 2)]
|
||||
private double SJphase = -100.0;
|
||||
|
||||
|
||||
#endregion Parameters
|
||||
|
||||
private TBars bars;
|
||||
|
||||
///////
|
||||
private JMA_Series fJma, sJma;
|
||||
///////
|
||||
|
||||
public DJMA_chart() {
|
||||
this.SeparateWindow = false;
|
||||
this.Name = "DJMA - Two JMAs";
|
||||
this.Description = "Jurik Moving Average description";
|
||||
this.AddLineSeries("JMA-fast", Color.Blue, 2, LineStyle.Solid);
|
||||
this.AddLineSeries("JMA-slow", Color.Green, 2, LineStyle.Solid);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnInit() {
|
||||
this.bars = new();
|
||||
this.fJma = new(source: bars.Select(this.FDataSource), period: this.FPeriod, phase: FJphase, vshort: FVshort, vlong: FVlong, useNaN: false);
|
||||
this.sJma = new(source: bars.Select(this.SDataSource), period: this.SPeriod, phase: SJphase, vshort: SVshort, vlong: SVlong, useNaN: false);
|
||||
}
|
||||
|
||||
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.SetValue(this.fJma[^1].v, lineIndex: 0);
|
||||
this.SetValue(this.sJma[^1].v, lineIndex: 1);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
private ENTROPY_Series indicator;
|
||||
///////
|
||||
|
||||
public ENTP_chart()
|
||||
{
|
||||
this.SeparateWindow = true;
|
||||
this.Name = "ENTROPY - Entropy (Unpredictability)";
|
||||
this.Description = "Entropy description";
|
||||
this.AddLineSeries("ENTROPY", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: true);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: false);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: false);
|
||||
Debug.WriteLine("Send to debug output.");
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class JMA_chart : QuanTAlib_Indicator {
|
||||
#endregion Parameters
|
||||
|
||||
///////
|
||||
private EMA_Series indicator;
|
||||
private JMA_Series indicator;
|
||||
///////
|
||||
|
||||
public JMA_chart() :base() {
|
||||
@@ -43,7 +43,7 @@ public class JMA_chart : QuanTAlib_Indicator {
|
||||
protected override void OnInit() {
|
||||
base.OnInit();
|
||||
indicator = new(source: bars.Select(DataSource), period: Period,
|
||||
// phase: Jphase, vshort: Vshort, vlong: Vlong,
|
||||
phase: Jphase, vshort: Vshort, vlong: Vlong,
|
||||
useNaN: true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
private KURTOSIS_Series indicator;
|
||||
///////
|
||||
|
||||
public KURT_chart()
|
||||
{
|
||||
this.SeparateWindow = true;
|
||||
this.Name = "KURTOSIS - Kurtosis (Flatness)";
|
||||
this.Description = "Kurtosis description";
|
||||
this.AddLineSeries("KURTOSIS", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: true);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: true);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class MAMA_chart : Indicator {
|
||||
#region Parameters
|
||||
|
||||
[InputParameter("Data source", 0, 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;
|
||||
|
||||
[InputParameter("Fastlimit", 1, 0, 1, 0.001, 5)]
|
||||
private double fastlimit = 0.5;
|
||||
|
||||
[InputParameter("Slowlimit", 2, 0, 1, 0.001, 5)]
|
||||
private double slowlimit = 0.05;
|
||||
#endregion Parameters
|
||||
|
||||
protected HistoricalData History;
|
||||
private TBars bars;
|
||||
///////
|
||||
private MAMA_Series indicator;
|
||||
///////
|
||||
|
||||
public MAMA_chart() :base() {
|
||||
Name = "MAMA - MESA Adaptive Moving Average";
|
||||
AddLineSeries(lineName: "MAMA", lineColor: Color.Yellow, lineWidth: 3,lineStyle: LineStyle.Solid);
|
||||
SeparateWindow = false;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnInit() {
|
||||
this.bars = new();
|
||||
|
||||
this.History = this.Symbol.GetHistory(period: this.HistoricalData.Period, fromTime: HistoricalData.FromTime);
|
||||
for (int i = this.History.Count - 1; i >= 0; i--) {
|
||||
var rec = this.History[i, SeekOriginHistory.Begin];
|
||||
bars.Add(rec.TimeLeft, rec[PriceType.Open],
|
||||
rec[PriceType.High], rec[PriceType.Low],
|
||||
rec[PriceType.Close], rec[PriceType.Volume]);
|
||||
}
|
||||
indicator = new(source: bars.Select(DataSource),
|
||||
fastlimit: fastlimit, slowlimit: fastlimit,
|
||||
useNaN: true)
|
||||
;
|
||||
}
|
||||
|
||||
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.SetValue(indicator[^1].v, lineIndex: 0);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: true);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator =
|
||||
new(source: bars.Select(this.DataSource), period: this.Period);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
private MEDIAN_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.bars = new();
|
||||
this.indicator =
|
||||
new(source: bars.Select(this.DataSource), period: this.Period);
|
||||
}
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator =
|
||||
new(source: bars.Select(this.DataSource), period: this.Period);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: true);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: false);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class RSI_chart : QuanTAlib_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;
|
||||
|
||||
[InputParameter("Overbought level", 2, 1, 100, 1, 1)]
|
||||
private int Overbought = 70;
|
||||
|
||||
[InputParameter("Oversold level", 2, 1, 100, 1, 1)]
|
||||
private int Oversold = 30;
|
||||
|
||||
#endregion Parameters
|
||||
|
||||
///////
|
||||
private RSI_Series indicator;
|
||||
///////
|
||||
|
||||
public RSI_chart() : base() {
|
||||
this.Name = "RSI - Relative Strength Index";
|
||||
this.Description = "RSI description";
|
||||
this.AddLineSeries("RSI", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
this.SeparateWindow = true;
|
||||
}
|
||||
|
||||
protected override void OnInit() {
|
||||
base.OnInit();
|
||||
indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: true);
|
||||
}
|
||||
|
||||
protected override void OnUpdate(UpdateArgs args) {
|
||||
base.OnUpdate(args);
|
||||
SetValue(indicator[^1].v, lineIndex: 0);
|
||||
if (indicator[^1].v >= Overbought)
|
||||
LinesSeries[0].SetMarker(0, color: Color.Red);
|
||||
if (indicator[^1].v <= Oversold)
|
||||
LinesSeries[0].SetMarker(0, color: Color.Red);
|
||||
}
|
||||
public override void OnPaintChart(PaintChartEventArgs args) {
|
||||
base.OnPaintChart(args);
|
||||
for (int i = firstOnScreenBarIndex; i <= lastOnScreenBarIndex; i++) {
|
||||
int xLeft = (int)Math.Round(mainWindow.CoordinatesConverter.GetChartX(Time(Count - i - 1)));
|
||||
int y = (int)Math.Round((mainWindow.CoordinatesConverter.GetChartY(Overbought)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////dotnet
|
||||
private SDEV_Series indicator;
|
||||
///////
|
||||
|
||||
public SDEV_chart()
|
||||
{
|
||||
this.SeparateWindow = true;
|
||||
this.Name = "SDEV - Standard Deviation";
|
||||
this.Description = "SDEV description";
|
||||
this.AddLineSeries("SDEV", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: true);
|
||||
}
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: true);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class SMA_chart : Indicator
|
||||
{
|
||||
#region Parameters
|
||||
|
||||
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
|
||||
private readonly 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 readonly int DataSource = 3;
|
||||
|
||||
#endregion Parameters
|
||||
|
||||
private TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: false);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class SMMA_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 TBars bars;
|
||||
|
||||
///////
|
||||
private SMMA_Series indicator;
|
||||
///////
|
||||
|
||||
public SMMA_chart()
|
||||
{
|
||||
this.SeparateWindow = false;
|
||||
this.Name = "SMMA - Smoothed Moving Average";
|
||||
this.Description = "Smoothed Moving Average description";
|
||||
this.AddLineSeries("SMMA", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: false);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////dotnet
|
||||
private VAR_Series indicator;
|
||||
///////
|
||||
|
||||
public VAR_chart()
|
||||
{
|
||||
this.SeparateWindow = true;
|
||||
this.Name = "VAR - Variance";
|
||||
this.Description = "VAR description";
|
||||
this.AddLineSeries("VAR", Color.RoyalBlue, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: true);
|
||||
}
|
||||
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
namespace QuanTAlib;
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
|
||||
public class WMAPE_chart : Indicator
|
||||
{
|
||||
#region Parameters
|
||||
|
||||
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
|
||||
private readonly 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 readonly int DataSource = 8;
|
||||
|
||||
#endregion Parameters
|
||||
|
||||
private TBars bars;
|
||||
|
||||
///////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.bars = new();
|
||||
this.indicator = new(source: this.bars.Select(this.DataSource), period: this.Period, useNaN: true);
|
||||
}
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
|
||||
this.SetValue(result, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
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 TBars bars;
|
||||
|
||||
///////
|
||||
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.bars = new();
|
||||
this.indicator = new(source: bars.Select(this.DataSource),
|
||||
period: this.Period, useNaN: false);
|
||||
}
|
||||
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);
|
||||
double result = this.indicator[this.indicator.Count - 1].v;
|
||||
this.SetValue(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class MovingAverage_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;
|
||||
|
||||
[InputParameter("Moving Average Type", 2, variants: new object[]
|
||||
{ "SMA", 0, "EMA", 1, "WMA", 2, "T3", 3, "SMMA", 4, "TRIMA", 5, "DWMA", 6, "FMA", 7, "DEMA", 8, "TEMA", 9,
|
||||
"ALMA", 10, "HMA", 11, "HEMA", 12, "MAMA", 13, "KAMA", 14, "ZLEMA", 15, "JMA", 16})]
|
||||
private int MAtype = 1;
|
||||
#endregion Parameters
|
||||
|
||||
protected HistoricalData History;
|
||||
private TBars bars ;
|
||||
|
||||
///////
|
||||
private TSeries indicator;
|
||||
///////
|
||||
|
||||
public MovingAverage_chart()
|
||||
{
|
||||
this.SeparateWindow = false;
|
||||
this.Name = "Flexible Moving Average";
|
||||
this.AddLineSeries("MA", Color.Yellow, 3, LineStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.bars = new();
|
||||
this.History = this.Symbol.GetHistory(period: this.HistoricalData.Period, fromTime: HistoricalData.FromTime);
|
||||
for (int i = this.History.Count - 1; i >= 0; i--) {
|
||||
var rec = this.History[i, SeekOriginHistory.Begin];
|
||||
bars.Add(rec.TimeLeft, rec[PriceType.Open],
|
||||
rec[PriceType.High], rec[PriceType.Low],
|
||||
rec[PriceType.Close], rec[PriceType.Volume]);
|
||||
}
|
||||
|
||||
switch (MAtype) {
|
||||
case 0:
|
||||
indicator = new SMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Simple Moving Average - SMA";
|
||||
break;
|
||||
case 1:
|
||||
indicator = new EMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Exponential Moving Average - EMA";
|
||||
break;
|
||||
case 2:
|
||||
indicator = new WMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Weighted Moving Average - WMA";
|
||||
break;
|
||||
case 3:
|
||||
indicator = new T3_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Tillson T3 Moving Average - T3";
|
||||
break;
|
||||
case 4:
|
||||
indicator = new SMMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Smoothed Moving Average - SMMA";
|
||||
break;
|
||||
case 5:
|
||||
indicator = new TRIMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Triangular Moving Average - TRIMA";
|
||||
break;
|
||||
case 6:
|
||||
indicator = new DWMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Double Weighted Moving Average - DWMA";
|
||||
break;
|
||||
case 7:
|
||||
indicator = new FMA_Series(source: bars.Select(this.DataSource), period: this.Period);
|
||||
this.Name = $"Fibonacci Moving Average - FMA";
|
||||
break;
|
||||
case 8:
|
||||
indicator = new DEMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Double Exponential Moving Average - DEMA";
|
||||
break;
|
||||
case 9:
|
||||
indicator = new TEMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Triple Exponential Moving Average - TEMA";
|
||||
break;
|
||||
case 10:
|
||||
indicator = new ALMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Arnaud Legoux Moving Average - ALMA";
|
||||
break;
|
||||
case 11:
|
||||
indicator = new HMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Hull Moving Average - HMA";
|
||||
break;
|
||||
case 12:
|
||||
indicator = new HEMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Hull-Exponential Moving Average - HEMA";
|
||||
break;
|
||||
case 13:
|
||||
double factor= 1.015 * Math.Exp(-0.043 * (double)this.Period);
|
||||
indicator = new MAMA_Series(source: bars.Select(this.DataSource),
|
||||
fastlimit: factor, slowlimit: factor*0.1,
|
||||
useNaN: false);
|
||||
this.Name = $"MESA Adaptive Moving Average - MAMA";
|
||||
break;
|
||||
case 14:
|
||||
indicator = new KAMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Kaufman's Adaptive Moving Average - KAMA";
|
||||
break;
|
||||
case 15:
|
||||
indicator = new ZLEMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Zero Lag Exponential Moving Average - ZLEMA";
|
||||
break;
|
||||
default:
|
||||
indicator = new JMA_Series(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
|
||||
this.Name = $"Jurik Moving Average - JMA";
|
||||
break;
|
||||
}
|
||||
this.Name = this.Name + $" ({Period}:{TBars.SelectStr(this.DataSource)})";
|
||||
}
|
||||
|
||||
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.SetValue(this.indicator[this.indicator.Count - 1].v);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user