Control Order of Signals

Hello

I am trying to create a moving average slope system using 2 X MAs. Code below shows what I am trying to do, I want to enter long when both MAs slope up, and short when both slope down. I want the sell/cover to exit the trade and go into a neutral position, and wait for the buy or sell signal again. So Sell can only trigger when Buy is active, and Cover can only trigger when Short is active. I thought the ExRem would achieve this but doesn't appear to work.

Shortup = ROC(ma1, 1) > 0;
Longup = ROC(ma2, 1) > 0;
Shortdown = ROC(ma1, 1) < 0;
Longdown = ROC(ma2, 1) < 0;

Buy = Shortup AND Longup;
Sell= Shortdown AND Longup;
Short = Shortdown AND Longdown;
Cover = Shortup AND Longdown;

//Stop Excessive / Keep Order of Signals
Buy = ExRem(Buy,Sell OR Cover);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover OR Sell);
Cover = ExRem(Cover,Short);

Am I using ExRem correctly, or dos this type of order need to be coded into the signals?

Thanks

You may want to try this variation..

Buy   = Cross(((ROC(ma1, 1) > 0) + (ROC(ma2, 1) > 0)), 1.5);
Short = Cross(((ROC(ma1, 1) < 0) + (ROC(ma2, 1) < 0)), 1.5);
Buy   = ExRem(Buy, Short);
Short = ExRem(Short, Buy);

bsb  = BarsSince(Buy);
bss  = BarsSince(Short);

Sell  =   Short OR ExRem((Nz(bss) > Nz(bsb)) AND Cross(((ROC(ma1, 1) <= 0) + (ROC(ma2, 1) <= 0)), 0.5), Buy);
Cover = Buy OR ExRem((Nz(bss) < Nz(bsb)) AND Cross(((ROC(ma1, 1) >= 0) + (ROC(ma2, 1) >= 0)), 0.5), Short);

This one will do so.

SetOption("ReverseSignalForcesExit", revrse = false);
SetPositionSize(1, spsPercentOfEquity);

ma1 = MA(C, 20);
ma2 = MA(C, 50);

Shortup = ROC(ma1, 1) > 0;
Longup = ROC(ma2, 1) > 0;
Shortdown = ROC(ma1, 1) < 0;
Longdown = ROC(ma2, 1) < 0;

Buy = Shortup AND Longup;
Sell = Shortdown AND Longup;
Short = Shortdown AND Longdown;
Cover = Shortup AND Longdown;

// If in Chart 
if ( Status("action") == actionIndicator ) {
	// Just for display of Sell arrow 
	// if there is reverse signal (revrse = true)
	Sell = Sell OR Short*revrse;
	// Just for display of Cover arrow 
	// if there is reverse signal (revrse = true)
	Cover = Cover OR Buy*revrse; 
	
	eq = Equity(1,0);

	Plot( C, "Price", colorDefault, styleBar );
	PlotShapes( Buy * shapeUpArrow, colorGreen, 0, L );
	PlotShapes( Sell * shapeDownArrow, colorRed, 0, H );
	PlotShapes( Short * shapeDownArrow,colorDarkRed, 0, H, -24 );
	PlotShapes( Cover * shapeUpArrow, colorAqua, 0, L, -24 );
}

(Set exit at reverse signal to true if you want to exit such occurrences.)