3MA Strategy with Dual Condition Entry

Hellio

I've been working on this strategy, and can't seem to get it right.

I want to execute a buy or sell only when the ma cross occurs whilst ma3 is either sloping up or down to help prevent entering counter-trend whipsaws. However, I want to close the trades only when the reverse cross happens regardless of ma3 condition.

ma1 = EMA(C,8)
ma2 = EMA(C,21)
ma3 = WMA(C,30)

MA3Rising = ROC(ma3, 5) > 0;
MA3Decline = ROC(ma3, 5) < 0;
EntryCross = Cross(ma1,ma2);
ExitCross = Cross(ma2,ma1);
 
Buy  = MA3Rising AND EntryCross;
Sell = MA3Decline AND ExitCross;
Short	=	ExitCross;
Cover	=	EntryCross;

// Plot Buy/Sell Signal Arrows
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBrown, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBrown, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorBlue, 0, H, Offset=40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorBlue, 0,H, Offset=50);
PlotShapes(IIf(Cover, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

Ay help is much appreciated

Thanks

Untested:

Buy  = MA3Rising AND EntryCross;
Sell = ExitCross;

Short =	MA3Decline AND ExitCross;
Cover =	EntryCross;
1 Like