Afirma + documentation +semver: patch

This commit is contained in:
Miha Kralj
2024-09-24 16:41:26 -07:00
parent 07efb4b0de
commit 133c65ceaf
250 changed files with 14425 additions and 713 deletions
+6 -7
View File
@@ -21,7 +21,7 @@ public abstract class AbstractIndicatorBase : Indicator
public PriceType SourcePrice { get; set; } = PriceType.Close;
[InputParameter(name: "Line smoothing", sortIndex: 19, minimum: 0.0, maximum: 1.0, increment: 0.1, decimalPlaces: 2)]
public double Tension { get; set; } = 0.2;
public double Tension = 0.2;
[InputParameter("Show cold values", sortIndex: 20)]
public bool ShowColdValues { get; set; } = true;
@@ -31,12 +31,14 @@ public abstract class AbstractIndicatorBase : Indicator
protected LineSeries? Series;
protected abstract AbstractBase MovingAverage { get; }
protected AbstractIndicatorBase()
protected AbstractIndicatorBase() : base()
{
OnBackGround = true;
SeparateWindow = false;
Series = new(name: $"Name", color: Color.Orange, width: 2, style: LineStyle.Solid);
AddLineSeries(Series);
InitIndicator();
}
protected virtual void InitIndicator()
@@ -69,10 +71,7 @@ public abstract class AbstractIndicatorBase : Indicator
{
base.OnPaintChart(args);
List<Point> allPoints = new List<Point>();
if (CurrentChart == null)
{
return;
}
if (CurrentChart == null) return;
Graphics gr = args.Graphics;
var mainWindow = CurrentChart.MainWindow;
@@ -103,7 +102,7 @@ public abstract class AbstractIndicatorBase : Indicator
private void DrawSmoothCombinedCurve(Graphics gr, List<Point> allPoints, int hotCount)
{
if (allPoints.Count < 2) { return; }
if (allPoints.Count < 2) return;
using (Pen defaultPen = new(Series!.Color, Series.Width) { DashStyle = ConvertLineStyleToDashStyle(Series.Style) })
using (Pen coldPen = new(Series!.Color, Series.Width) { DashStyle = DashStyle.Dot })
+5 -4
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class AlmaIndicator : IndicatorBase
{
@@ -7,21 +7,22 @@ public class AlmaIndicator : IndicatorBase
public int Period { get; set; } = 10;
[InputParameter("Offset", sortIndex: 5)]
public double Offset { get; set; } = 0.85;
public double Offset = 0.85;
[InputParameter("Sigma", sortIndex: 6)]
public double Sigma { get; set; } = 6.0;
public double Sigma = 6.0;
private Alma? ma;
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"ALMA {Period} : {Offset:F2} : {Sigma:F0} : {SourceName}";
public AlmaIndicator()
public AlmaIndicator() : base()
{
Name = "ALMA - Arnaud Legoux Moving Average";
}
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Alma(period: Period, offset: Offset, sigma: Sigma);
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class DemaIndicator : IndicatorBase
{
@@ -9,13 +9,14 @@ public class DemaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"DEMA {Period} : {SourceName}";
public DemaIndicator()
public DemaIndicator() : base()
{
Name = "DEMA - Double Exponential Moving Average";
}
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Dema(period: Period);
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class DsmaIndicator : IndicatorBase
{
@@ -12,7 +12,7 @@ public class DsmaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"DSMA {Period} : {Scale:F2} : {SourceName}";
public DsmaIndicator()
public DsmaIndicator() : base()
{
Name = "DSMA - Deviation Scaled Moving Average";
}
@@ -21,5 +21,6 @@ public class DsmaIndicator : IndicatorBase
{
ma = new Dsma(Period, Scale);
MinHistoryDepths = ma.WarmupPeriod;
base.InitIndicator();
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class DwmaIndicator : IndicatorBase
{
@@ -11,7 +11,7 @@ public class DwmaIndicator : IndicatorBase
public override string ShortName => $"DWMA {Period} : {SourceName}";
public DwmaIndicator()
public DwmaIndicator() : base()
{
Name = "DWMA - Double Weighted Moving Average";
}
@@ -19,5 +19,6 @@ public class DwmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Dwma(Period);
base.InitIndicator();
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class EmaIndicator : IndicatorBase
{
@@ -13,7 +13,7 @@ public class EmaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"EMA {Period} : {SourceName}";
public EmaIndicator()
public EmaIndicator() : base()
{
Name = "EMA - Exponential Moving Average";
Description = "Exponential Moving Average";
@@ -21,6 +21,7 @@ public class EmaIndicator : IndicatorBase
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Ema(period: Period, useSma: UseSma);
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class EpmaIndicator : IndicatorBase
{
@@ -10,13 +10,14 @@ public class EpmaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"EPMA {Period} : {SourceName}";
public EpmaIndicator()
public EpmaIndicator() : base()
{
Name = "EPMA - Endpoint Moving Average";
}
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Epma(period: Period);
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class FramaIndicator : IndicatorBase
{
@@ -11,7 +11,7 @@ public class FramaIndicator : IndicatorBase
public override string ShortName => $"FRAMA {Period} : {SourceName}";
public FramaIndicator()
public FramaIndicator() : base()
{
Name = "FRAMA - Fractal Adaptive Moving Average";
}
@@ -19,5 +19,6 @@ public class FramaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Frama(Period);
base.InitIndicator();
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class FwmaIndicator : IndicatorBase
{
@@ -11,7 +11,7 @@ public class FwmaIndicator : IndicatorBase
public override string ShortName => $"FWMA {Period} : {SourceName}";
public FwmaIndicator()
public FwmaIndicator() : base()
{
Name = "FWMA - Fibonacci-Weighted Moving Average";
}
@@ -19,5 +19,6 @@ public class FwmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Fwma(Period);
base.InitIndicator();
}
}
+3 -2
View File
@@ -1,5 +1,5 @@
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
using QuanTAlib;
public class GmaIndicator : IndicatorBase
{
@@ -11,7 +11,7 @@ public class GmaIndicator : IndicatorBase
public override string ShortName => $"GMA {Period} : {SourceName}";
public GmaIndicator()
public GmaIndicator() : base()
{
Name = "GMA - Gaussian-Weighted Moving Average";
}
@@ -19,5 +19,6 @@ public class GmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Gma(Period);
base.InitIndicator();
}
}
+2 -1
View File
@@ -11,7 +11,7 @@ public class HmaIndicator : IndicatorBase
public override string ShortName => $"HMA {Period} : {SourceName}";
public HmaIndicator()
public HmaIndicator() : base()
{
Name = "HMA - Hull Moving Average";
}
@@ -19,5 +19,6 @@ public class HmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Hma(Period);
base.InitIndicator();
}
}
+2 -1
View File
@@ -7,7 +7,7 @@ public class HtitIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"HTIT : {SourceName}";
public HtitIndicator()
public HtitIndicator() : base()
{
Name = "HTIT - Hilbert Transform Instantaneous Trendline";
}
@@ -16,5 +16,6 @@ public class HtitIndicator : IndicatorBase
{
ma = new Htit();
MinHistoryDepths = ma.WarmupPeriod;
base.InitIndicator();
}
}
+5 -1
View File
@@ -17,13 +17,17 @@ public class HwmaIndicator : IndicatorBase
public override string ShortName => $"HWMA {nA:F2} : {nB:F2} : {nC:F2} : {SourceName}";
public HwmaIndicator()
public HwmaIndicator() : base()
{
Name = "HWMA - Holt-Winter Moving Average";
}
protected override void InitIndicator()
{
//nA = 2 / (1 + (double)Period);
//nB = 1 / (double)Period;
//nC = 1 / (double)Period;
ma = new Hwma(nA: nA, nB: nB, nC: nC);
base.InitIndicator();
}
}
+3 -2
View File
@@ -7,13 +7,13 @@ public class JmaIndicator : IndicatorBase
public int Period { get; set; } = 10;
[InputParameter("Phase", sortIndex: 2, -100, 100, 1, 0)]
public int Phase { get; set; }
public int Phase { get; set; } = 0;
private Jma? ma;
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"JMA {Period} : {Phase} : {SourceName}";
public JmaIndicator()
public JmaIndicator() : base()
{
Name = "JMA - Jurik Moving Average";
}
@@ -21,5 +21,6 @@ public class JmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Jma(period: Period, phase: (double)Phase);
base.InitIndicator();
}
}
+2 -1
View File
@@ -15,7 +15,7 @@ public class KamaIndicator : IndicatorBase
public override string ShortName => $"KAMA {Period} : {Fast} : {Slow} : {SourceName}";
public KamaIndicator()
public KamaIndicator() : base()
{
Name = "KAMA - Kaufman's Adaptive Moving Average";
}
@@ -23,5 +23,6 @@ public class KamaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Kama(Period, Fast, Slow);
base.InitIndicator();
}
}
+2 -1
View File
@@ -10,7 +10,7 @@ public class LtmaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"Laguerre {Gamma:F2} : {SourceName}";
public LtmaIndicator()
public LtmaIndicator() : base()
{
Name = "LTMA - Laguerre Transform Moving Average";
}
@@ -18,5 +18,6 @@ public class LtmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Ltma(gamma: Gamma);
base.InitIndicator();
}
}
+3 -2
View File
@@ -7,19 +7,20 @@ public class MaafIndicator : IndicatorBase
public int Period { get; set; } = 39;
[InputParameter("Threshold", sortIndex: 5, minimum: 0, maximum: 1, increment: 0.001, decimalPlaces:3)]
public double Threshold { get; set; } = 0.002;
public double Threshold = 0.002;
private Maaf? ma;
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"MAAF {Period} : {Threshold:F2} : {SourceName}";
public MaafIndicator()
public MaafIndicator() : base()
{
Name = "MAAF - Median-Average Adaptive Filter";
}
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Maaf(Period: Period, Threshold: Threshold);
}
}
+2 -1
View File
@@ -12,7 +12,7 @@ public class MamaIndicator : IndicatorBase
public override string ShortName => $"MAMA : {Fast} : {Slow} : {SourceName}";
public MamaIndicator()
public MamaIndicator() : base()
{
Name = "MAMA - MESA Adaptive Moving Average";
}
@@ -20,5 +20,6 @@ public class MamaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Mama(Fast, Slow);
base.InitIndicator();
}
}
+2 -1
View File
@@ -15,7 +15,7 @@ public class MgdiIndicator : IndicatorBase
public override string ShortName => $"MGDI {Period} : {kfactor:F2} : {SourceName}";
public MgdiIndicator()
public MgdiIndicator() : base()
{
Name = "MGDI - McGinley Dynamic Index";
}
@@ -23,5 +23,6 @@ public class MgdiIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Mgdi(period: Period, kFactor: kfactor);
base.InitIndicator();
}
}
+2 -1
View File
@@ -10,13 +10,14 @@ public class MmaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"MMA {Period} : {SourceName}";
public MmaIndicator()
public MmaIndicator() : base()
{
Name = "MMA - Modified Moving Average";
}
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Mma(period: Period);
}
}
+2 -1
View File
@@ -16,7 +16,7 @@ public class QemaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"QEMA {k1:F2} : {k2:F2} : {k3:F2} : {k4:F2} :{SourceName}";
public QemaIndicator()
public QemaIndicator() : base()
{
Name = "QEMA - Quad Exponential Moving Average";
Description = "Quad Exponential Moving Average";
@@ -24,6 +24,7 @@ public class QemaIndicator : IndicatorBase
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Qema(k1, k2, k3, k4);
}
}
+2 -1
View File
@@ -13,13 +13,14 @@ public class RemaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"REMA {Period} : {Lambda:F2} : {SourceName}";
public RemaIndicator()
public RemaIndicator() : base()
{
Name = "REMA - Regularized Exponential Moving Average";
}
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Rema(period: Period, lambda: Lambda);
}
}
+2 -1
View File
@@ -11,7 +11,7 @@ public class RmaIndicator : IndicatorBase
public override string ShortName => $"RMA {Period} : {SourceName}";
public RmaIndicator()
public RmaIndicator() : base()
{
Name = "RMA - wildeR Moving Average";
}
@@ -19,5 +19,6 @@ public class RmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Rma(Period);
base.InitIndicator();
}
}
+2 -1
View File
@@ -10,7 +10,7 @@ public class SinemaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"SINEMA {Period} : {SourceName}";
public SinemaIndicator()
public SinemaIndicator() : base()
{
Name = "SINEMA - Sine-Weighted Moving Average";
}
@@ -18,5 +18,6 @@ public class SinemaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Sinema(Period);
base.InitIndicator();
}
}
+2 -1
View File
@@ -11,7 +11,7 @@ public class SmaIndicator : IndicatorBase
public override string ShortName => $"SMA {Period} : {SourceName}";
public SmaIndicator()
public SmaIndicator() : base()
{
Name = "SMA - Simple Moving Average";
}
@@ -19,5 +19,6 @@ public class SmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Sma(Period);
base.InitIndicator();
}
}
+2 -1
View File
@@ -11,7 +11,7 @@ public class SmmaIndicator : IndicatorBase
public override string ShortName => $"SMMA {Period} : {SourceName}";
public SmmaIndicator()
public SmmaIndicator() : base()
{
Name = "SMMA - Smoothed Moving Average";
}
@@ -19,5 +19,6 @@ public class SmmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Smma(Period);
base.InitIndicator();
}
}
+3 -2
View File
@@ -10,13 +10,13 @@ public class T3Indicator : IndicatorBase
public double Vfactor { get; set; } = 0.62;
[InputParameter("Use SMA for warmup", sortIndex: 3)]
public bool UseSma { get; set; }
public bool UseSma { get; set; } = false;
private T3? ma;
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"T3 {Period} : {Vfactor:F2} : {SourceName}";
public T3Indicator()
public T3Indicator() : base()
{
Name = "T3 - Tillson T3 Moving Average";
}
@@ -24,5 +24,6 @@ public class T3Indicator : IndicatorBase
protected override void InitIndicator()
{
ma = new T3(period: Period, vfactor: Vfactor, useSma: UseSma);
base.InitIndicator();
}
}
+2 -1
View File
@@ -10,13 +10,14 @@ public class TemaIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"TEMA {Period} : {SourceName}";
public TemaIndicator()
public TemaIndicator() : base()
{
Name = "TEMA - Triple Exponential Moving Average";
}
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Tema(period: Period);
}
}
+2 -1
View File
@@ -11,7 +11,7 @@ public class TrimaIndicator : IndicatorBase
public override string ShortName => $"TRIMA {Period} : {SourceName}";
public TrimaIndicator()
public TrimaIndicator() : base()
{
Name = "TRIMA - Triangular Moving Average";
}
@@ -19,5 +19,6 @@ public class TrimaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Trima(Period);
base.InitIndicator();
}
}
+2 -1
View File
@@ -15,7 +15,7 @@ public class VidyaIndicator : IndicatorBase
public override string ShortName => $"VIDYA {Period} : {SourceName}";
public VidyaIndicator()
public VidyaIndicator() : base()
{
Name = "VIDYA - Variable Index Dynamic Average";
}
@@ -23,5 +23,6 @@ public class VidyaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Vidya(Period, LPeriod, Alpha);
base.InitIndicator();
}
}
+2 -1
View File
@@ -11,7 +11,7 @@ public class WmaIndicator : IndicatorBase
public override string ShortName => $"WMA {Period} : {SourceName}";
public WmaIndicator()
public WmaIndicator() : base()
{
Name = "WMA - Weighted Moving Average";
}
@@ -19,5 +19,6 @@ public class WmaIndicator : IndicatorBase
protected override void InitIndicator()
{
ma = new Wma(Period);
base.InitIndicator();
}
}
+2 -1
View File
@@ -11,13 +11,14 @@ public class ZlemaIndicator : IndicatorBase
public override string ShortName => $"ZLEMA {Period} : {SourceName}";
public ZlemaIndicator()
public ZlemaIndicator() : base()
{
Name = "ZLEMA - Weighted Moving Average";
}
protected override void InitIndicator()
{
base.InitIndicator();
ma = new Zlema(Period);
}
}
+13 -10
View File
@@ -3,11 +3,10 @@ using TradingPlatform.BusinessLayer;
using TradingPlatform.BusinessLayer.Chart;
using System.Runtime.CompilerServices;
using System.Drawing.Drawing2D;
using QuanTAlib;
using System.Collections;
using TradingPlatform.BusinessLayer.TimeSync;
namespace QuanTAlib;
#pragma warning disable CA1416 // Validate platform compatibility
public abstract class IndicatorBase : Indicator, IWatchlistIndicator
{
@@ -28,7 +27,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
[InputParameter("Show cold values", sortIndex: 20)]
public bool ShowColdValues { get; set; } = true;
public int MinHistoryDepths { get; set; }
public int MinHistoryDepths;
// LineSeries.LineSeries(string, Color, int, LineStyle)'
@@ -38,7 +37,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
int IWatchlistIndicator.MinHistoryDepths => 0;
protected IndicatorBase()
protected IndicatorBase() : base()
{
OnBackGround = true;
SeparateWindow = false;
@@ -46,9 +45,13 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
Series = new(name: $"{Name}", color: Color.Yellow, width: 2, style: LineStyle.Solid);
AddLineSeries(Series);
InitIndicator();
}
protected abstract void InitIndicator();
protected virtual void InitIndicator()
{
SourceName = GetName(Source);
}
protected override void OnInit()
{
@@ -92,7 +95,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
{
base.OnPaintChart(args);
List<Point> allPoints = new List<Point>();
if (CurrentChart == null) { return; }
if (CurrentChart == null) return;
Graphics gr = args.Graphics;
var mainWindow = this.CurrentChart.Windows[args.WindowIndex];
@@ -123,7 +126,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
private void DrawSmoothCombinedCurve(Graphics gr, List<Point> allPoints, int hotCount)
{
if (allPoints.Count < 2) { return; }
if (allPoints.Count < 2) return;
using (Pen defaultPen = new(Series!.Color, Series.Width) { DashStyle = ConvertLineStyleToDashStyle(Series.Style) })
using (Pen coldPen = new(Series!.Color, Series.Width) { DashStyle = DashStyle.Dot })
@@ -143,7 +146,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
}
}
}
private static DashStyle ConvertLineStyleToDashStyle(LineStyle lineStyle)
private DashStyle ConvertLineStyleToDashStyle(LineStyle lineStyle)
{
return lineStyle switch
{
@@ -154,7 +157,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
_ => DashStyle.Solid,
};
}
protected static void DrawText(Graphics gr, string text, Rectangle clientRect)
protected void DrawText(Graphics gr, string text, Rectangle clientRect)
{
Font font = new Font("Inter", 8);
SizeF textSize = gr.MeasureString(text, font);
@@ -164,7 +167,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
gr.FillRectangle(SystemBrushes.ControlDarkDark, textRect);
gr.DrawString(text, font, Brushes.White, new PointF(textRect.X + 6, textRect.Y + 5));
}
protected static string GetName(int pType)
protected string GetName(int pType)
{
return pType switch
{
+2 -1
View File
@@ -10,7 +10,7 @@ public class EntropyIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => entropy!;
public override string ShortName => $"ENTROPY {Period} : {SourceName}";
public EntropyIndicator()
public EntropyIndicator() : base()
{
Name = "ENTROPY - Entropy";
SeparateWindow = true;
@@ -20,5 +20,6 @@ public class EntropyIndicator : IndicatorBase
{
entropy = new(Period);
MinHistoryDepths = entropy.WarmupPeriod;
base.InitIndicator();
}
}
+2 -1
View File
@@ -10,7 +10,7 @@ public class KurtosisIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => kurtosis!;
public override string ShortName => $"KURTOSIS {Period} : {SourceName}";
public KurtosisIndicator()
public KurtosisIndicator() : base()
{
Name = "KURTOSIS - Relative Flatness";
SeparateWindow = true;
@@ -20,5 +20,6 @@ public class KurtosisIndicator : IndicatorBase
{
kurtosis = new(Period);
MinHistoryDepths = kurtosis.WarmupPeriod;
base.InitIndicator();
}
}
+2 -1
View File
@@ -13,7 +13,7 @@ public class MaxIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => ma!;
public override string ShortName => $"MAX {Period} : {Decay:F2} : {SourceName}";
public MaxIndicator()
public MaxIndicator() : base()
{
Name = "MAX - Maximum value (with decay) ";
}
@@ -23,5 +23,6 @@ public class MaxIndicator : IndicatorBase
ma = new Max(Period, Decay);
MinHistoryDepths = ma.WarmupPeriod;
Source = 2;
base.InitIndicator();
}
}
+2 -1
View File
@@ -9,7 +9,7 @@ public class MedianIndicator : IndicatorBase
private Median? med;
protected override AbstractBase QuanTAlib => med!;
public override string ShortName => $"MEDIAN {Period} : {SourceName}";
public MedianIndicator()
public MedianIndicator() : base()
{
Name = "MEDIAN - Median historical value";
}
@@ -18,5 +18,6 @@ public class MedianIndicator : IndicatorBase
{
med = new Median(Period);
MinHistoryDepths = med.WarmupPeriod;
base.InitIndicator();
}
}
+2 -1
View File
@@ -12,7 +12,7 @@ public class MinIndicator : IndicatorBase
private Min? mi;
protected override AbstractBase QuanTAlib => mi!;
public override string ShortName => $"MIN {Period} : {Decay:F2} : {SourceName}";
public MinIndicator()
public MinIndicator() : base()
{
Name = "MIN - Minimum value (with decay)";
}
@@ -22,5 +22,6 @@ public class MinIndicator : IndicatorBase
mi = new Min(Period, Decay);
MinHistoryDepths = mi.WarmupPeriod;
Source = 3;
base.InitIndicator();
}
}
+2 -1
View File
@@ -9,7 +9,7 @@ public class ModeIndicator : IndicatorBase
private Mode? mode;
protected override AbstractBase QuanTAlib => mode!;
public override string ShortName => $"MODE {Period} : {SourceName}";
public ModeIndicator()
public ModeIndicator() : base()
{
Name = "MODE - Most frequent historical value";
}
@@ -18,5 +18,6 @@ public class ModeIndicator : IndicatorBase
{
mode = new Mode(Period);
MinHistoryDepths = mode.WarmupPeriod;
base.InitIndicator();
}
}
+2 -1
View File
@@ -12,7 +12,7 @@ public class PercentileIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => percentile!;
public override string ShortName => $"PERCENTILE {Period} {Percent:F0}% : {SourceName}";
public PercentileIndicator()
public PercentileIndicator() : base()
{
Name = "PERCENTILE - n-th Percentile ";
SeparateWindow = false;
@@ -22,6 +22,7 @@ public class PercentileIndicator : IndicatorBase
{
percentile = new(Period, Percent);
MinHistoryDepths = percentile.WarmupPeriod;
base.InitIndicator();
}
}
+2 -1
View File
@@ -11,7 +11,7 @@ public class SkewIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => skew!;
public override string ShortName => $"SKEW {Period} : {SourceName}";
public SkewIndicator()
public SkewIndicator() : base()
{
Name = "SKEW - Skewness";
SeparateWindow = true;
@@ -21,5 +21,6 @@ public class SkewIndicator : IndicatorBase
{
skew = new(Period);
MinHistoryDepths = skew.WarmupPeriod;
base.InitIndicator();
}
}
+3 -2
View File
@@ -7,12 +7,12 @@ public class StddevIndicator : IndicatorBase
public int Period { get; set; } = 20;
[InputParameter("Population", sortIndex: 2)]
public bool IsPopulation { get; set; }
public bool IsPopulation { get; set; } = false;
private Stddev? stddev;
protected override AbstractBase QuanTAlib => stddev!;
public override string ShortName => $"STDDEV {Period} : {SourceName}";
public StddevIndicator()
public StddevIndicator() : base()
{
Name = "STDDEV - Standard Deviation";
SeparateWindow = true;
@@ -22,5 +22,6 @@ public class StddevIndicator : IndicatorBase
{
stddev = new(Period, IsPopulation);
MinHistoryDepths = stddev.WarmupPeriod;
base.InitIndicator();
}
}
+3 -2
View File
@@ -7,12 +7,12 @@ public class VarianceIndicator : IndicatorBase
public int Period { get; set; } = 20;
[InputParameter("Population", sortIndex: 2)]
public bool IsPopulation { get; set; }
public bool IsPopulation { get; set; } = false;
private Variance? variance;
protected override AbstractBase QuanTAlib => variance!;
public override string ShortName => $"VAR {Period} : {SourceName}";
public VarianceIndicator()
public VarianceIndicator() : base()
{
Name = "VAR - Variance";
SeparateWindow = true;
@@ -23,5 +23,6 @@ public class VarianceIndicator : IndicatorBase
SeparateWindow = true;
variance = new(Period, IsPopulation);
MinHistoryDepths = variance.WarmupPeriod;
base.InitIndicator();
}
}
+2 -1
View File
@@ -10,7 +10,7 @@ public class ZScoreIndicator : IndicatorBase
protected override AbstractBase QuanTAlib => zScore!;
public override string ShortName => $"ZSCORE {Period} : {SourceName}";
public ZScoreIndicator()
public ZScoreIndicator() : base()
{
Name = "ZSCORE - Standard Score";
SeparateWindow = true;
@@ -20,6 +20,7 @@ public class ZScoreIndicator : IndicatorBase
{
zScore = new(Period);
MinHistoryDepths = zScore.WarmupPeriod;
base.InitIndicator();
}
}
+12 -9
View File
@@ -28,7 +28,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
[InputParameter("Show cold values", sortIndex: 20)]
public bool ShowColdValues { get; set; } = true;
public int MinHistoryDepths { get; set; }
public int MinHistoryDepths;
// LineSeries.LineSeries(string, Color, int, LineStyle)'
@@ -38,7 +38,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
int IWatchlistIndicator.MinHistoryDepths => 0;
protected IndicatorBase()
protected IndicatorBase() : base()
{
OnBackGround = true;
SeparateWindow = false;
@@ -46,14 +46,17 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
Series = new(name: $"{Name}", color: Color.RoyalBlue, width: 2, style: LineStyle.Solid);
AddLineSeries(Series);
InitIndicator();
}
protected abstract void InitIndicator();
protected virtual void InitIndicator()
{
SourceName = GetName(Source);
}
protected override void OnInit()
{
InitIndicator();
SourceName = GetName(Source);
base.OnInit();
}
@@ -93,7 +96,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
{
base.OnPaintChart(args);
List<Point> allPoints = new List<Point>();
if (CurrentChart == null) { return; }
if (CurrentChart == null) return;
Graphics gr = args.Graphics;
@@ -125,7 +128,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
private void DrawSmoothCombinedCurve(Graphics gr, List<Point> allPoints, int hotCount)
{
if (allPoints.Count < 2) { return; }
if (allPoints.Count < 2) return;
using (Pen defaultPen = new(Series!.Color, Series.Width) { DashStyle = ConvertLineStyleToDashStyle(Series.Style) })
using (Pen coldPen = new(Series!.Color, Series.Width) { DashStyle = DashStyle.Dot })
@@ -145,7 +148,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
}
}
}
private static DashStyle ConvertLineStyleToDashStyle(LineStyle lineStyle)
private DashStyle ConvertLineStyleToDashStyle(LineStyle lineStyle)
{
return lineStyle switch
{
@@ -156,7 +159,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
_ => DashStyle.Solid,
};
}
protected static void DrawText(Graphics gr, string text, Rectangle clientRect)
protected void DrawText(Graphics gr, string text, Rectangle clientRect)
{
Font font = new Font("Inter", 8);
SizeF textSize = gr.MeasureString(text, font);
@@ -166,7 +169,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
gr.FillRectangle(SystemBrushes.ControlDarkDark, textRect);
gr.DrawString(text, font, Brushes.White, new PointF(textRect.X + 6, textRect.Y + 5));
}
protected static string GetName(int pType)
protected string GetName(int pType)
{
return pType switch
{