mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-15 09:08:04 +00:00
refresh with new QT DLL
This commit is contained in:
@@ -1,24 +1,41 @@
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class AtrIndicator : IndicatorBarBase
|
||||
public class AtrIndicator : Indicator, IWatchlistIndicator
|
||||
{
|
||||
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
|
||||
public int Period { get; set; } = 20;
|
||||
[InputParameter("Periods", sortIndex: 1, 1, 2000, 1, 0)]
|
||||
public int Periods { get; set; } = 20;
|
||||
|
||||
private Atr? atr;
|
||||
protected override AbstractBase QuanTAlib => atr!;
|
||||
public override string ShortName => $"ATR {Period}";
|
||||
protected LineSeries? AtrSeries;
|
||||
public int MinHistoryDepths => 2;
|
||||
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
||||
|
||||
public AtrIndicator()
|
||||
{
|
||||
Name = "ATR - Average True Range";
|
||||
Description = "Measures market volatility by calculating the average range between high and low prices.";
|
||||
SeparateWindow = true;
|
||||
|
||||
AtrSeries = new("ATR", Color.Blue, 2, LineStyle.Solid);
|
||||
AddLineSeries(AtrSeries);
|
||||
}
|
||||
|
||||
protected override void InitIndicator()
|
||||
protected override void OnInit()
|
||||
{
|
||||
atr = new(Period);
|
||||
MinHistoryDepths = atr!.WarmupPeriod;
|
||||
atr = new Atr(Periods);
|
||||
base.OnInit();
|
||||
}
|
||||
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
TBar input = IndicatorExtensions.GetInputBar(this, args);
|
||||
TValue result = atr!.Calc(input);
|
||||
|
||||
AtrSeries!.SetValue(result.Value);
|
||||
}
|
||||
|
||||
public override string ShortName => $"ATR ({Periods})";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user