Wabbit,
This is what I came up with on the latch design into the system but it still allow for more then one trade at a time before an exit.
pds:=2;
XAT:=2;
{Zero Lag MA}
EMA8:=Mov(2*(Mov(C,8/2,W))-Mov(C,8,W),2,W);
EMA17:=Mov(2*(Mov(C,17/2,W))-Mov(C,17,W),4,W);
{Entry Signals}
MACBuy:=If((EMA8-EMA17)>Mov((EMA8-EMA17),9,E) AND Alert((EMA8-EMA17)<Mov((EMA8-EMA17),9,E),pds),1,0);
MACSell:=If((EMA8-EMA17)<Mov((EMA8-EMA17),9,E) AND Alert((EMA8-EMA17)>Mov((EMA8-EMA17),9,E),pds),-1,0);
{Buy & Sell Exit Alerts}
LE:=HHV(H - XAT*ATR(5),10);{For Long}
SE:=LLV(L + (XAT*2)*ATR(5),10);{For Short}
MACBuyExit:=If(L<LE AND Alert(L>LE,pds) OR L<HHV(H - (XAT*2)*ATR(5),10) AND Alert(L>HHV(H - (XAT*2)*ATR(5),10),pds),-1,0);
MACSellExit:=If(H>SE AND Alert(H<SE,pds) OR H>LLV(L + (XAT*2)*ATR(5),10) AND Alert(H<LLV(L + (XAT*2)*ATR(5),10),pds),1,0);
{Buy & sell latchs-turning On & Off}
IBuy:=Cum(MACBuy+MACBuyExit>-1)=1;
ISell:=Cum(MACSell+MACSellExit>-1)=1;
BuyEnterExits:=BarsSince(IBuy OR MACBuy=1)<BarsSince(IBuy OR MACBuyExit=-1);
SellEnterExits:=BarsSince(ISell OR MACSell=-1)<BarsSince(ISell OR MACSellExit=1);
{Formula}
Buy:=If(BuyEnterExits=BuyEnterExits AND Alert(BuyEnterExits=0,pds) AND SellEnterExits=0,1,0);
Sell:=If(SellEnterExits=SellEnterExits AND Alert(SellEnterExits=0,pds) AND BuyEnterExits=0,-1,0);
BuyExits:=If(BuyEnterExits=0 AND Alert(BuyEnterExits=1,pds),-2,0);
SellExits:=If(SellEnterExits=0 AND Alert(SellEnterExits=SellEnterExits,pds),2,0);
Buy+Sell+BuyExits+SellExits