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