Periods -> Period, DataSource attribute

This commit is contained in:
Miha Kralj
2024-11-08 17:11:18 -08:00
parent 61a16bd5e3
commit 5bcdf8d614
75 changed files with 370 additions and 1053 deletions
+7 -18
View File
@@ -8,8 +8,8 @@ public class AfirmaIndicator : Indicator, IWatchlistIndicator
[InputParameter("Taps (number of weights)", sortIndex: 1, 1, 2000, 1, 0)]
public int Taps { get; set; } = 6;
[InputParameter("Periods for lowpass cutoff", sortIndex: 2, 1, 2000, 1, 0)]
public int Periods { get; set; } = 6;
[InputParameter("Period for lowpass cutoff", sortIndex: 2, 1, 2000, 1, 0)]
public int Period { get; set; } = 6;
[InputParameter("Window Type", sortIndex: 3, variants: [
"Rectangular", Afirma.WindowType.Rectangular,
@@ -20,18 +20,7 @@ public class AfirmaIndicator : Indicator, IWatchlistIndicator
])]
public Afirma.WindowType Window { get; set; } = Afirma.WindowType.Hanning1;
[InputParameter("Data source", sortIndex: 4, variants: [
"Open", SourceType.Open,
"High", SourceType.High,
"Low", SourceType.Low,
"Close", SourceType.Close,
"HL/2 (Median)", SourceType.HL2,
"OC/2 (Midpoint)", SourceType.OC2,
"OHL/3 (Mean)", SourceType.OHL3,
"HLC/3 (Typical)", SourceType.HLC3,
"OHLC/4 (Average)", SourceType.OHLC4,
"HLCC/4 (Weighted)", SourceType.HLCC4
])]
[IndicatorExtensions.DataSourceInput]
public SourceType Source { get; set; } = SourceType.Close;
[InputParameter("Show cold values", sortIndex: 21)]
@@ -39,7 +28,7 @@ public class AfirmaIndicator : Indicator, IWatchlistIndicator
private Afirma? ma;
protected LineSeries? Series;
protected string? SourceName;
public int MinHistoryDepths => Periods + Taps;
public int MinHistoryDepths => Period + Taps;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public AfirmaIndicator()
@@ -50,13 +39,13 @@ public class AfirmaIndicator : Indicator, IWatchlistIndicator
Name = "AFIRMA - Adaptive Finite Impulse Response Moving Average";
Description = "Adaptive Finite Impulse Response Moving Average with ARMA component";
Series = new(name: $"AFIRMA {Taps}:{Periods}:{Window}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
Series = new(name: $"AFIRMA {Taps}:{Period}:{Window}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
AddLineSeries(Series);
}
protected override void OnInit()
{
ma = new Afirma(periods: Periods, taps: Taps, window: Window);
ma = new Afirma(periods: Period, taps: Taps, window: Window);
SourceName = Source.ToString();
base.OnInit();
}
@@ -70,7 +59,7 @@ public class AfirmaIndicator : Indicator, IWatchlistIndicator
Series!.SetValue(result.Value);
}
public override string ShortName => $"AFIRMA {Taps}:{Periods}:{Window}:{SourceName}";
public override string ShortName => $"AFIRMA {Taps}:{Period}:{Window}:{SourceName}";
public override void OnPaintChart(PaintChartEventArgs args)
{