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
+6 -6
View File
@@ -5,15 +5,15 @@ namespace QuanTAlib;
public class AdxIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Periods", sortIndex: 1, 1, 2000, 1, 0)]
public int Periods { get; set; } = 14;
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
public int Period { get; set; } = 14;
[InputParameter("Show cold values", sortIndex: 21)]
public bool ShowColdValues { get; set; } = true;
private Adx? adx;
protected LineSeries? AdxSeries;
public int MinHistoryDepths => Math.Max(5, Periods * 3); // Need extra periods for ADX calculation
public int MinHistoryDepths => Math.Max(5, Period * 3); // Need extra periods for ADX calculation
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public AdxIndicator()
@@ -22,13 +22,13 @@ public class AdxIndicator : Indicator, IWatchlistIndicator
Description = "Measures the strength of a trend, regardless of its direction.";
SeparateWindow = true;
AdxSeries = new($"ADX {Periods}", color: IndicatorExtensions.Momentum, 2, LineStyle.Solid);
AdxSeries = new($"ADX {Period}", color: IndicatorExtensions.Momentum, 2, LineStyle.Solid);
AddLineSeries(AdxSeries);
}
protected override void OnInit()
{
adx = new Adx(Periods);
adx = new Adx(Period);
base.OnInit();
}
@@ -43,7 +43,7 @@ public class AdxIndicator : Indicator, IWatchlistIndicator
#pragma warning disable CA1416 // Validate platform compatibility
public override string ShortName => $"ADX ({Periods})";
public override string ShortName => $"ADX ({Period})";
public override void OnPaintChart(PaintChartEventArgs args)
{
+6 -6
View File
@@ -5,15 +5,15 @@ namespace QuanTAlib;
public class AdxrIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Periods", sortIndex: 1, 1, 2000, 1, 0)]
public int Periods { get; set; } = 14;
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
public int Period { get; set; } = 14;
[InputParameter("Show cold values", sortIndex: 21)]
public bool ShowColdValues { get; set; } = true;
private Adxr? adxr;
protected LineSeries? AdxrSeries;
public int MinHistoryDepths => Math.Max(5, Periods * 4); // Need extra periods for ADXR calculation
public int MinHistoryDepths => Math.Max(5, Period * 4); // Need extra periods for ADXR calculation
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public AdxrIndicator()
@@ -22,13 +22,13 @@ public class AdxrIndicator : Indicator, IWatchlistIndicator
Description = "Measures trend strength by comparing current ADX with historical ADX values.";
SeparateWindow = true;
AdxrSeries = new($"ADXR {Periods}", Color.Blue, 2, LineStyle.Solid);
AdxrSeries = new($"ADXR {Period}", Color.Blue, 2, LineStyle.Solid);
AddLineSeries(AdxrSeries);
}
protected override void OnInit()
{
adxr = new Adxr(Periods);
adxr = new Adxr(Period);
base.OnInit();
}
@@ -43,7 +43,7 @@ public class AdxrIndicator : Indicator, IWatchlistIndicator
#pragma warning disable CA1416 // Validate platform compatibility
public override string ShortName => $"ADXR ({Periods})";
public override string ShortName => $"ADXR ({Period})";
public override void OnPaintChart(PaintChartEventArgs args)
{
+1 -12
View File
@@ -11,18 +11,7 @@ public class ApoIndicator : Indicator, IWatchlistIndicator
[InputParameter("Slow Period", sortIndex: 2, 1, 2000, 1, 0)]
public int SlowPeriod { get; set; } = 26;
[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;
+8 -8
View File
@@ -5,8 +5,8 @@ namespace QuanTAlib;
public class DmiIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Periods", sortIndex: 1, 1, 2000, 1, 0)]
public int Periods { get; set; } = 14;
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
public int Period { get; set; } = 14;
[InputParameter("Show cold values", sortIndex: 21)]
public bool ShowColdValues { get; set; } = true;
@@ -14,7 +14,7 @@ public class DmiIndicator : Indicator, IWatchlistIndicator
private Dmi? dmi;
protected LineSeries? PlusDiSeries;
protected LineSeries? MinusDiSeries;
public int MinHistoryDepths => Math.Max(5, Periods * 2);
public int MinHistoryDepths => Math.Max(5, Period * 2);
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public DmiIndicator()
@@ -23,22 +23,22 @@ public class DmiIndicator : Indicator, IWatchlistIndicator
Description = "Identifies the directional movement of a price by comparing successive highs and lows.";
SeparateWindow = true;
PlusDiSeries = new($"+DI {Periods}", color: Color.Red, 2, LineStyle.Solid);
MinusDiSeries = new($"-DI {Periods}", color: Color.Blue, 2, LineStyle.Solid);
PlusDiSeries = new($"+DI {Period}", color: Color.Red, 2, LineStyle.Solid);
MinusDiSeries = new($"-DI {Period}", color: Color.Blue, 2, LineStyle.Solid);
AddLineSeries(PlusDiSeries);
AddLineSeries(MinusDiSeries);
}
protected override void OnInit()
{
dmi = new Dmi(Periods);
dmi = new Dmi(Period);
base.OnInit();
}
protected override void OnUpdate(UpdateArgs args)
{
TBar input = IndicatorExtensions.GetInputBar(this, args);
var result = dmi!.Calc(input);
dmi!.Calc(input);
PlusDiSeries!.SetValue(dmi.PlusDI);
MinusDiSeries!.SetValue(dmi.MinusDI);
@@ -48,7 +48,7 @@ public class DmiIndicator : Indicator, IWatchlistIndicator
#pragma warning disable CA1416 // Validate platform compatibility
public override string ShortName => $"DMI ({Periods})";
public override string ShortName => $"DMI ({Period})";
public override void OnPaintChart(PaintChartEventArgs args)
{
+10 -10
View File
@@ -5,11 +5,11 @@ namespace QuanTAlib;
public class DmxIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("DMI Periods", sortIndex: 1, 1, 2000, 1, 0)]
public int DmiPeriods { get; set; } = 14;
[InputParameter("DMI Period", sortIndex: 1, 1, 2000, 1, 0)]
public int DmiPeriod { get; set; } = 14;
[InputParameter("JMA Smoothing Periods", sortIndex: 2, 1, 2000, 1, 0)]
public int JmaPeriods { get; set; } = 12;
[InputParameter("JMA Smoothing Period", sortIndex: 2, 1, 2000, 1, 0)]
public int JmaPeriod { get; set; } = 12;
[InputParameter("JMA Phase", sortIndex: 3, -100, 100, 1, 0)]
public int JmaPhase { get; set; } = 100;
@@ -23,7 +23,7 @@ public class DmxIndicator : Indicator, IWatchlistIndicator
private Dmx? dmx;
protected LineSeries? PlusDiSeries;
protected LineSeries? MinusDiSeries;
public int MinHistoryDepths => Math.Max(5, (DmiPeriods + JmaPeriods) * 2);
public int MinHistoryDepths => Math.Max(5, (DmiPeriod + JmaPeriod) * 2);
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public DmxIndicator()
@@ -32,22 +32,22 @@ public class DmxIndicator : Indicator, IWatchlistIndicator
Description = "An enhanced version of DMI using JMA smoothing for better noise reduction and responsiveness.";
SeparateWindow = true;
PlusDiSeries = new($"+DI {DmiPeriods}", color: Color.Red, 2, LineStyle.Solid);
MinusDiSeries = new($"-DI {DmiPeriods}", color: Color.Blue, 2, LineStyle.Solid);
PlusDiSeries = new($"+DI {DmiPeriod}", color: Color.Red, 2, LineStyle.Solid);
MinusDiSeries = new($"-DI {DmiPeriod}", color: Color.Blue, 2, LineStyle.Solid);
AddLineSeries(PlusDiSeries);
AddLineSeries(MinusDiSeries);
}
protected override void OnInit()
{
dmx = new Dmx(DmiPeriods, JmaPeriods, JmaPhase, JmaFactor);
dmx = new Dmx(DmiPeriod, JmaPeriod, JmaPhase, JmaFactor);
base.OnInit();
}
protected override void OnUpdate(UpdateArgs args)
{
TBar input = IndicatorExtensions.GetInputBar(this, args);
var result = dmx!.Calc(input);
dmx!.Calc(input);
PlusDiSeries!.SetValue(dmx.PlusDI);
MinusDiSeries!.SetValue(dmx.MinusDI);
@@ -57,7 +57,7 @@ public class DmxIndicator : Indicator, IWatchlistIndicator
#pragma warning disable CA1416 // Validate platform compatibility
public override string ShortName => $"DMX ({DmiPeriods})";
public override string ShortName => $"DMX ({DmiPeriod})";
public override void OnPaintChart(PaintChartEventArgs args)
{
+1 -12
View File
@@ -8,18 +8,7 @@ public class DpoIndicator : Indicator, IWatchlistIndicator
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
public int Period { get; set; } = 20;
[InputParameter("Data source", sortIndex: 2, 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: 3)]
+1 -12
View File
@@ -19,18 +19,7 @@ public class MacdIndicator : Indicator, IWatchlistIndicator
[InputParameter("Use SMA for warmup period", sortIndex: 2)]
public bool UseSMA { get; set; } = false;
[InputParameter("Data source", sortIndex: 3, 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)]
+1 -12
View File
@@ -8,18 +8,7 @@ public class MomIndicator : Indicator
[InputParameter("Period", sortIndex: 1, minimum: 1, maximum: 2000, increment: 1)]
public int Period { get; set; } = 10;
[InputParameter("Data source", sortIndex: 2, 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)]
+1 -12
View File
@@ -11,18 +11,7 @@ public class PmoIndicator : Indicator
[InputParameter("Second Period", sortIndex: 2, minimum: 1, maximum: 2000, increment: 1)]
public int Period2 { get; set; } = 20;
[InputParameter("Data source", sortIndex: 3, 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)]
+1 -12
View File
@@ -11,18 +11,7 @@ public class PoIndicator : Indicator
[InputParameter("Slow Period", sortIndex: 2, minimum: 1, maximum: 2000, increment: 1)]
public int SlowPeriod { get; set; } = 21;
[InputParameter("Data source", sortIndex: 3, 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)]
+1 -12
View File
@@ -11,18 +11,7 @@ public class PpoIndicator : Indicator
[InputParameter("Slow Period", sortIndex: 2, minimum: 1, maximum: 2000, increment: 1)]
public int SlowPeriod { get; set; } = 26;
[InputParameter("Data source", sortIndex: 3, 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)]
+1 -12
View File
@@ -8,18 +8,7 @@ public class RocIndicator : Indicator, IWatchlistIndicator
[InputParameter("Period", sortIndex: 1, minimum: 1, maximum: 2000, increment: 1)]
public int Period { get; set; } = 12;
[InputParameter("Data source", sortIndex: 2, 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)]
+1 -12
View File
@@ -8,18 +8,7 @@ public class TrixIndicator : Indicator
[InputParameter("Period", sortIndex: 1, minimum: 1, maximum: 2000, increment: 1)]
public int Period { get; set; } = 18;
[InputParameter("Data source", sortIndex: 2, 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)]
+1 -12
View File
@@ -14,18 +14,7 @@ public class VelIndicator : Indicator, IWatchlistIndicator
[InputParameter("Factor", sortIndex: 3, minimum: 0.1, maximum: 0.9, increment: 0.1, decimalPlaces: 2)]
public double Factor { get; set; } = 0.25;
[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)]
+8 -8
View File
@@ -5,8 +5,8 @@ namespace QuanTAlib;
public class VortexIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Periods", sortIndex: 1, 1, 2000, 1, 0)]
public int Periods { get; set; } = 14;
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
public int Period { get; set; } = 14;
[InputParameter("Show cold values", sortIndex: 21)]
public bool ShowColdValues { get; set; } = true;
@@ -16,7 +16,7 @@ public class VortexIndicator : Indicator, IWatchlistIndicator
protected LineSeries? PlusLine;
protected LineSeries? MinusLine;
protected LineSeries? ZeroLine;
public int MinHistoryDepths => Math.Max(5, Periods * 2);
public int MinHistoryDepths => Math.Max(5, Period * 2);
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;
public VortexIndicator()
@@ -25,9 +25,9 @@ public class VortexIndicator : Indicator, IWatchlistIndicator
Description = "A technical indicator consisting of two oscillating lines that identify trend reversals";
SeparateWindow = true;
ValueSeries = new($"VORTEX({Periods})", color: IndicatorExtensions.Momentum, 2, LineStyle.Solid);
PlusLine = new($"VI+({Periods})", color: Color.Green, 2, LineStyle.Solid);
MinusLine = new($"VI-({Periods})", color: Color.Red, 2, LineStyle.Solid);
ValueSeries = new($"VORTEX({Period})", color: IndicatorExtensions.Momentum, 2, LineStyle.Solid);
PlusLine = new($"VI+({Period})", color: Color.Green, 2, LineStyle.Solid);
MinusLine = new($"VI-({Period})", color: Color.Red, 2, LineStyle.Solid);
ZeroLine = new("Zero", Color.Gray, 1, LineStyle.Dot);
AddLineSeries(ValueSeries);
@@ -38,7 +38,7 @@ public class VortexIndicator : Indicator, IWatchlistIndicator
protected override void OnInit()
{
vortex = new Vortex(Periods);
vortex = new Vortex(Period);
base.OnInit();
}
@@ -59,7 +59,7 @@ public class VortexIndicator : Indicator, IWatchlistIndicator
#pragma warning disable CA1416 // Validate platform compatibility
public override string ShortName => $"VORTEX({Periods})";
public override string ShortName => $"VORTEX({Period})";
public override void OnPaintChart(PaintChartEventArgs args)
{