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?