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
+46
View File
@@ -0,0 +1,46 @@
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class ATR_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private readonly int Period = 10;
#endregion Parameters
private readonly TBars bars = new();
///////
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()
{
this.ShortName =
"ATR (" + this.Period + ")";
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);
}
}