Files
QuanTAlib/quantower/Volatility/JvoltyIndicator.cs
T

47 lines
1.2 KiB
C#
Raw Normal View History

2024-10-14 08:45:32 -07:00
using System.Drawing;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class JvoltyIndicator : Indicator, IWatchlistIndicator
{
2024-11-08 17:11:18 -08:00
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
public int Period { get; set; } = 14;
2024-10-14 08:45:32 -07:00
2024-11-08 17:11:18 -08:00
[IndicatorExtensions.DataSourceInput]
2024-10-16 18:28:06 -07:00
public SourceType Source { get; set; } = SourceType.Close;
private Jma? jma;
2024-10-14 08:45:32 -07:00
protected LineSeries? JvoltySeries;
public static int MinHistoryDepths => 2;
2024-10-16 18:28:06 -07:00
2024-10-14 08:45:32 -07:00
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public JvoltyIndicator()
{
Name = "JVOLTY - Mark Jurik's Volatility";
Description = "Measures market volatility according to Mark Jurik.";
SeparateWindow = true;
2024-11-06 20:56:32 -08:00
JvoltySeries = new("JVOLTY", color: IndicatorExtensions.Volatility, 2, LineStyle.Solid);
2024-10-14 08:45:32 -07:00
AddLineSeries(JvoltySeries);
}
protected override void OnInit()
{
2024-11-08 17:11:18 -08:00
jma = new(Period);
2024-10-14 08:45:32 -07:00
base.OnInit();
}
protected override void OnUpdate(UpdateArgs args)
{
2024-10-16 18:28:06 -07:00
TValue input = this.GetInputValue(args, Source);
jma!.Calc(input);
JvoltySeries!.SetValue(jma.Volty);
2024-10-14 08:45:32 -07:00
}
2024-11-08 17:11:18 -08:00
public override string ShortName => $"JVOLTY ({Period})";
2024-10-14 08:45:32 -07:00
}