mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-13 16:18:05 +00:00
Squash
dotcover s1 .sln s1 s1 s2 s3 s4 s5 s1 s2 x x2 x3 x4 x5 x6 x1 sonarcube cleanup1 sonarcube cleanup2 sonarcube cleanup 3 fixes q q q q q q q q q1 q2 q q1 codacy 1
This commit is contained in:
@@ -3,10 +3,11 @@ 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
|
||||
{
|
||||
@@ -27,7 +28,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
|
||||
|
||||
[InputParameter("Show cold values", sortIndex: 20)]
|
||||
public bool ShowColdValues { get; set; } = true;
|
||||
public int MinHistoryDepths;
|
||||
public int MinHistoryDepths { get; set; }
|
||||
|
||||
// LineSeries.LineSeries(string, Color, int, LineStyle)'
|
||||
|
||||
@@ -37,7 +38,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
|
||||
|
||||
int IWatchlistIndicator.MinHistoryDepths => 0;
|
||||
|
||||
protected IndicatorBase() : base()
|
||||
protected IndicatorBase()
|
||||
{
|
||||
OnBackGround = true;
|
||||
SeparateWindow = false;
|
||||
@@ -45,13 +46,9 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
|
||||
Series = new(name: $"{Name}", color: Color.Yellow, width: 2, style: LineStyle.Solid);
|
||||
|
||||
AddLineSeries(Series);
|
||||
InitIndicator();
|
||||
}
|
||||
|
||||
protected virtual void InitIndicator()
|
||||
{
|
||||
SourceName = GetName(Source);
|
||||
}
|
||||
protected abstract void InitIndicator();
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
@@ -95,7 +92,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];
|
||||
@@ -126,7 +123,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 })
|
||||
@@ -146,7 +143,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
|
||||
}
|
||||
}
|
||||
}
|
||||
private DashStyle ConvertLineStyleToDashStyle(LineStyle lineStyle)
|
||||
private static DashStyle ConvertLineStyleToDashStyle(LineStyle lineStyle)
|
||||
{
|
||||
return lineStyle switch
|
||||
{
|
||||
@@ -157,7 +154,7 @@ public abstract class IndicatorBase : Indicator, IWatchlistIndicator
|
||||
_ => DashStyle.Solid,
|
||||
};
|
||||
}
|
||||
protected void DrawText(Graphics gr, string text, Rectangle clientRect)
|
||||
protected static void DrawText(Graphics gr, string text, Rectangle clientRect)
|
||||
{
|
||||
Font font = new Font("Inter", 8);
|
||||
SizeF textSize = gr.MeasureString(text, font);
|
||||
@@ -167,7 +164,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 string GetName(int pType)
|
||||
protected static string GetName(int pType)
|
||||
{
|
||||
return pType switch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user