mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-18 02:28:05 +00:00
Afirma + documentation +semver: patch
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user