mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-16 01:28:05 +00:00
refresh with new QT DLL
This commit is contained in:
@@ -1,29 +1,44 @@
|
||||
using System.Drawing;
|
||||
using TradingPlatform.BusinessLayer;
|
||||
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class HistoricalIndicator : IndicatorBase
|
||||
public class HistoricalIndicator : 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;
|
||||
|
||||
[InputParameter("Annualized", sortIndex: 2)]
|
||||
public bool IsAnnualized { get; set; } = true;
|
||||
|
||||
private Historical? historical;
|
||||
protected override AbstractBase QuanTAlib => historical!;
|
||||
public override string ShortName => $"Historical Volatility {Period}{(IsAnnualized ? " - Annualized" : "")} : {SourceName}";
|
||||
protected LineSeries? HvSeries;
|
||||
public int MinHistoryDepths => Periods;
|
||||
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
||||
|
||||
public HistoricalIndicator() : base()
|
||||
public HistoricalIndicator()
|
||||
{
|
||||
Name = "HV - Historical Volatility";
|
||||
Description = "Measures price fluctuations over time, indicating market volatility based on past price movements.";
|
||||
SeparateWindow = true;
|
||||
|
||||
HvSeries = new("HV", Color.Blue, 2, LineStyle.Solid);
|
||||
AddLineSeries(HvSeries);
|
||||
}
|
||||
|
||||
protected override void InitIndicator()
|
||||
protected override void OnInit()
|
||||
{
|
||||
historical = new(Period, IsAnnualized);
|
||||
MinHistoryDepths = historical.WarmupPeriod;
|
||||
base.InitIndicator();
|
||||
historical = new Historical(Periods, IsAnnualized);
|
||||
base.OnInit();
|
||||
}
|
||||
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
TBar input = IndicatorExtensions.GetInputBar(this, args);
|
||||
TValue result = historical!.Calc(input);
|
||||
|
||||
HvSeries!.SetValue(result.Value);
|
||||
}
|
||||
|
||||
public override string ShortName => $"HV ({Periods}{(IsAnnualized ? " - Annualized" : "")})";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user