Skip to content

Commit

Permalink
Periods -> Period, DataSource attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mihakralj committed Nov 9, 2024
1 parent 61a16bd commit 5bcdf8d
Show file tree
Hide file tree
Showing 75 changed files with 378 additions and 1,061 deletions.
25 changes: 7 additions & 18 deletions quantower/Averages/AfirmaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -20,26 +20,15 @@ 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)]
public bool ShowColdValues { get; set; } = true;
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()
Expand All @@ -50,13 +39,13 @@ public AfirmaIndicator()
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();
}
Expand All @@ -70,7 +59,7 @@ protected override void OnUpdate(UpdateArgs args)
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)
{
Expand Down
13 changes: 1 addition & 12 deletions quantower/Averages/AlmaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@ public class AlmaIndicator : Indicator, IWatchlistIndicator
[InputParameter("Sigma", sortIndex: 3, minimum: 0, maximum: 100, decimalPlaces: 1)]
public double Sigma { get; set; } = 6.0;

[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)]
Expand Down
13 changes: 1 addition & 12 deletions quantower/Averages/DemaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ public class DemaIndicator : Indicator, IWatchlistIndicator
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
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)]
Expand Down
13 changes: 1 addition & 12 deletions quantower/Averages/DsmaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@ public class DsmaIndicator : Indicator, IWatchlistIndicator
[InputParameter("Scale factor", sortIndex: 2, minimum: 0.01, maximum: 1.0, increment: 0.01, decimalPlaces: 2)]
public double Scale { get; set; } = 0.5;

[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)]
Expand Down
13 changes: 1 addition & 12 deletions quantower/Averages/DwmaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ public class DwmaIndicator : Indicator, IWatchlistIndicator
[InputParameter("Period", sortIndex: 1, 1, 2000, 1, 0)]
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)]
Expand Down
25 changes: 7 additions & 18 deletions quantower/Averages/EmaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,12 @@ namespace QuanTAlib;

public class EmaIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Periods", sortIndex: 1, 1, 1000, 1, 0)]
public int Periods { get; set; } = 10;
[InputParameter("Period", sortIndex: 1, 1, 1000, 1, 0)]
public int Period { get; set; } = 10;
[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)]
Expand All @@ -30,10 +19,10 @@ public class EmaIndicator : Indicator, IWatchlistIndicator
private Ema? ma;
protected LineSeries? Series;
protected string? SourceName;
public int MinHistoryDepths => Periods;
public int MinHistoryDepths => Period;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;

public override string ShortName => $"EMA {Periods}:{SourceName}";
public override string ShortName => $"EMA {Period}:{SourceName}";

public EmaIndicator()
{
Expand All @@ -42,13 +31,13 @@ public EmaIndicator()
SourceName = Source.ToString();
Name = "EMA - Exponential Moving Average";
Description = "Exponential Moving Average";
Series = new(name: $"EMA {Periods}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
Series = new(name: $"EMA {Period}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
AddLineSeries(Series);
}

protected override void OnInit()
{
ma = new Ema(Periods, useSma: UseSMA);
ma = new Ema(Period, useSma: UseSMA);
SourceName = Source.ToString();
base.OnInit();
}
Expand Down
25 changes: 7 additions & 18 deletions quantower/Averages/EpmaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ namespace QuanTAlib;

public class EpmaIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Periods", sortIndex: 1, 1, 1000, 1, 0)]
public int Periods { get; set; } = 10;
[InputParameter("Period", sortIndex: 1, 1, 1000, 1, 0)]
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)]
Expand All @@ -28,10 +17,10 @@ public class EpmaIndicator : Indicator, IWatchlistIndicator
private Epma? ma;
protected LineSeries? Series;
protected string? SourceName;
public int MinHistoryDepths => Periods;
public int MinHistoryDepths => Period;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;

public override string ShortName => $"EPMA {Periods}:{SourceName}";
public override string ShortName => $"EPMA {Period}:{SourceName}";

public EpmaIndicator()
{
Expand All @@ -40,13 +29,13 @@ public EpmaIndicator()
SourceName = Source.ToString();
Name = "EPMA - Exponential Percentage Moving Average";
Description = "Exponential Percentage Moving Average";
Series = new(name: $"EPMA {Periods}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
Series = new(name: $"EPMA {Period}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
AddLineSeries(Series);
}

protected override void OnInit()
{
ma = new Epma(Periods);
ma = new Epma(Period);
SourceName = Source.ToString();
base.OnInit();
}
Expand Down
25 changes: 7 additions & 18 deletions quantower/Averages/FramaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ namespace QuanTAlib;

public class FramaIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Periods", sortIndex: 1, 2, 1000, 1, 0)]
public int Periods { get; set; } = 10;
[InputParameter("Period", sortIndex: 1, 2, 1000, 1, 0)]
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)]
Expand All @@ -28,10 +17,10 @@ public class FramaIndicator : Indicator, IWatchlistIndicator
private Frama? ma;
protected LineSeries? Series;
protected string? SourceName;
public int MinHistoryDepths => Periods * 2;
public int MinHistoryDepths => Period * 2;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;

public override string ShortName => $"FRAMA {Periods}:{SourceName}";
public override string ShortName => $"FRAMA {Period}:{SourceName}";

public FramaIndicator()
{
Expand All @@ -40,13 +29,13 @@ public FramaIndicator()
SourceName = Source.ToString();
Name = "FRAMA - Fractal Adaptive Moving Average";
Description = "Fractal Adaptive Moving Average";
Series = new(name: $"FRAMA {Periods}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
Series = new(name: $"FRAMA {Period}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
AddLineSeries(Series);
}

protected override void OnInit()
{
ma = new Frama(Periods);
ma = new Frama(Period);
SourceName = Source.ToString();
base.OnInit();
}
Expand Down
25 changes: 7 additions & 18 deletions quantower/Averages/FwmaIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,10 @@ namespace QuanTAlib;

public class FwmaIndicator : Indicator, IWatchlistIndicator
{
[InputParameter("Periods", sortIndex: 1, 1, 1000, 1, 0)]
public int Periods { get; set; } = 10;
[InputParameter("Period", sortIndex: 1, 1, 1000, 1, 0)]
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)]
Expand All @@ -28,10 +17,10 @@ public class FwmaIndicator : Indicator, IWatchlistIndicator
private Fwma? ma;
protected LineSeries? Series;
protected string? SourceName;
public int MinHistoryDepths => Periods;
public int MinHistoryDepths => Period;
int IWatchlistIndicator.MinHistoryDepths => MinHistoryDepths;

public override string ShortName => $"FWMA {Periods}:{SourceName}";
public override string ShortName => $"FWMA {Period}:{SourceName}";

public FwmaIndicator()
{
Expand All @@ -40,13 +29,13 @@ public FwmaIndicator()
SourceName = Source.ToString();
Name = "FWMA - Fibonacci Weighted Moving Average";
Description = "Fibonacci Weighted Moving Average";
Series = new(name: $"FWMA {Periods}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
Series = new(name: $"FWMA {Period}", color: IndicatorExtensions.Averages, width: 2, style: LineStyle.Solid);
AddLineSeries(Series);
}

protected override void OnInit()
{
ma = new Fwma(Periods);
ma = new Fwma(Period);
SourceName = Source.ToString();
base.OnInit();
}
Expand Down
Loading

0 comments on commit 5bcdf8d

Please sign in to comment.