# 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;

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

//Stop Excessive / Keep Order of Signals
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);

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;

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)