mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-17 01:58:06 +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 RealizedIndicator : IndicatorBase
|
||||
public class RealizedIndicator : 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 Realized? realized;
|
||||
protected override AbstractBase QuanTAlib => realized!;
|
||||
public override string ShortName => $"Realized Volatility {Period}{(IsAnnualized ? " - Annualized" : "")} : {SourceName}";
|
||||
protected LineSeries? RvSeries;
|
||||
public int MinHistoryDepths => Periods;
|
||||
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
|
||||
|
||||
public RealizedIndicator() : base()
|
||||
public RealizedIndicator()
|
||||
{
|
||||
Name = "RV - Realized Volatility";
|
||||
Description = "Measures actual price volatility over a specific period, useful for risk assessment and forecasting.";
|
||||
SeparateWindow = true;
|
||||
|
||||
RvSeries = new("RV", Color.Blue, 2, LineStyle.Solid);
|
||||
AddLineSeries(RvSeries);
|
||||
}
|
||||
|
||||
protected override void InitIndicator()
|
||||
protected override void OnInit()
|
||||
{
|
||||
realized = new(Period, IsAnnualized);
|
||||
MinHistoryDepths = realized.WarmupPeriod;
|
||||
base.InitIndicator();
|
||||
realized = new Realized(Periods, IsAnnualized);
|
||||
base.OnInit();
|
||||
}
|
||||
|
||||
protected override void OnUpdate(UpdateArgs args)
|
||||
{
|
||||
TBar input = IndicatorExtensions.GetInputBar(this, args);
|
||||
TValue result = realized!.Calc(input);
|
||||
|
||||
RvSeries!.SetValue(result.Value);
|
||||
}
|
||||
|
||||
public override string ShortName => $"RV ({Periods}{(IsAnnualized ? " - Annualized" : "")})";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user