Signed-off-by: Miha Kralj <miha@kraljfamily.net>

workflow

workflow

Signed-off-by: Miha Kralj <miha@kraljfamily.net>

Refactor charts


KAMA


build

build

build

build
This commit is contained in:
Miha Kralj
2022-04-23 20:10:30 -07:00
parent ee8b07bb37
commit 2a73615161
36 changed files with 599 additions and 288 deletions
+5 -9
View File
@@ -7,12 +7,12 @@ public class SMA_chart : Indicator
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private int Period = 10;
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 int DataSource = 3;
private readonly int DataSource = 3;
#endregion Parameters
@@ -36,11 +36,9 @@ public class SMA_chart : Indicator
"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)
}
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
@@ -48,8 +46,6 @@ public class SMA_chart : Indicator
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);
}