mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-07 21:47:43 +00:00
Update 2MASlope_chart.cs
This commit is contained in:
@@ -50,6 +50,8 @@ public class MovingAverageSlope_chart : Indicator {
|
||||
private TSeries MA1, MA2;
|
||||
private LINREG_Series sMA1, sMA2;
|
||||
private CROSS_Series sig1, sig2;
|
||||
|
||||
private bool inLong, inShort;
|
||||
///////
|
||||
|
||||
public MovingAverageSlope_chart() {
|
||||
@@ -240,31 +242,37 @@ public class MovingAverageSlope_chart : Indicator {
|
||||
this.LinesSeries[1].SetMarker(0,s2Color);
|
||||
|
||||
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.LinesSeries[(this.MA1[^1].v < this.MA2[^1].v)? 0 : 1 ].SetMarker(0, new IndicatorLineMarker(Color.LimeGreen, bottomIcon: IndicatorLineMarkerIconType.UpArrow));
|
||||
}
|
||||
else {
|
||||
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 (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.LinesSeries[(this.MA1[^1].v > this.MA2[^1].v) ? 0 : 1].SetMarker(0, new IndicatorLineMarker(Color.OrangeRed, upperIcon: IndicatorLineMarkerIconType.UpArrow));
|
||||
|
||||
}
|
||||
else {
|
||||
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) {
|
||||
base.OnPaintChart(args);
|
||||
|
||||
@@ -90,7 +90,6 @@ public class TrailingStop_chart : Indicator {
|
||||
this.SetValue(_ratchetL, lineIndex: 1);
|
||||
this.SetValue(_tslineS, lineIndex: 2);
|
||||
this.SetValue(_ratchetS, lineIndex: 3);
|
||||
|
||||
}
|
||||
|
||||
public override void OnPaintChart(PaintChartEventArgs args) {
|
||||
|
||||
Reference in New Issue
Block a user