Update 2MASlope_chart.cs

This commit is contained in:
Miha Kralj
2023-04-27 22:30:13 -07:00
parent 50591596af
commit 3b71ac70c8
2 changed files with 15 additions and 8 deletions
+15 -7
View File
@@ -50,6 +50,8 @@ public class MovingAverageSlope_chart : Indicator {
private TSeries MA1, MA2; private TSeries MA1, MA2;
private LINREG_Series sMA1, sMA2; private LINREG_Series sMA1, sMA2;
private CROSS_Series sig1, sig2; private CROSS_Series sig1, sig2;
private bool inLong, inShort;
/////// ///////
public MovingAverageSlope_chart() { public MovingAverageSlope_chart() {
@@ -240,31 +242,37 @@ public class MovingAverageSlope_chart : Indicator {
this.LinesSeries[1].SetMarker(0,s2Color); this.LinesSeries[1].SetMarker(0,s2Color);
if (sig1[^1].v > 0 || sig2[^1].v > 0) { if (sig1[^1].v > 0 || sig2[^1].v > 0) {
if (sMA1[^1].v >= 0 && sMA2[^1].v >= 0) if (sMA1[^1].v >= 0 && sMA2[^1].v >= 0 && LongTrades)
{ {
inLong = true;
this.BeginCloud(0, 1, Color.FromArgb(127, Color.DarkGreen)); this.BeginCloud(0, 1, Color.FromArgb(127, Color.DarkGreen));
this.LinesSeries[(this.MA1[^1].v < this.MA2[^1].v)? 0 : 1 ].SetMarker(0, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.UpArrow)); this.LinesSeries[(this.MA1[^1].v < this.MA2[^1].v)? 0 : 1 ].SetMarker(0, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.UpArrow));
} }
else { else {
this.EndCloud(0, 1, Color.Empty); this.EndCloud(0, 1, Color.Empty);
this.LinesSeries[(this.MA1[^1].v < this.MA2[^1].v) ? 1 : 0].SetMarker(1, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.DownArrow)); if (inShort)
{
this.LinesSeries[(this.MA1[^1].v < this.MA2[^1].v) ? 1 : 0].SetMarker(1, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.DownArrow));
inShort = false;
}
} }
} }
if (sig1[^1].v < 0 || sig2[^1].v < 0) { if (sig1[^1].v < 0 || sig2[^1].v < 0) {
if (sMA1[^1].v <= 0 && sMA2[^1].v <= 0) if (sMA1[^1].v <= 0 && sMA2[^1].v <= 0 && ShortTrades)
{ {
inShort = true;
this.BeginCloud(0, 1, Color.FromArgb(100, Color.Red)); this.BeginCloud(0, 1, Color.FromArgb(100, Color.Red));
this.LinesSeries[(this.MA1[^1].v > this.MA2[^1].v) ? 0 : 1].SetMarker(0, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.UpArrow)); this.LinesSeries[(this.MA1[^1].v > this.MA2[^1].v) ? 0 : 1].SetMarker(0, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.UpArrow));
} }
else { else {
this.EndCloud(0, 1, Color.Empty); this.EndCloud(0, 1, Color.Empty);
this.LinesSeries[(this.MA1[^1].v > this.MA2[^1].v)?1:0].SetMarker(1, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.DownArrow)); if (inLong) {
LinesSeries[(this.MA1[^1].v > this.MA2[^1].v)?1:0].SetMarker(1, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.DownArrow));
inLong = false;
}
} }
} }
} }
public override void OnPaintChart(PaintChartEventArgs args) { public override void OnPaintChart(PaintChartEventArgs args) {
base.OnPaintChart(args); base.OnPaintChart(args);
-1
View File
@@ -90,7 +90,6 @@ public class TrailingStop_chart : Indicator {
this.SetValue(_ratchetL, lineIndex: 1); this.SetValue(_ratchetL, lineIndex: 1);
this.SetValue(_tslineS, lineIndex: 2); this.SetValue(_tslineS, lineIndex: 2);
this.SetValue(_ratchetS, lineIndex: 3); this.SetValue(_ratchetS, lineIndex: 3);
} }
public override void OnPaintChart(PaintChartEventArgs args) { public override void OnPaintChart(PaintChartEventArgs args) {