When trading live this strategy doesn't display the trailing stop order and viewing the 'Order and Position Tracker' Window the strategy tab says I have 0 positions.
If possible I'd like to enter a position and turn this strategy on when I'm ready to have it automate my trailing stop.
Any help would be greatly appreciated.
Here's my code:
=============
Code: Select all
Variables:
mytrailL(0), mytrailS(0),ema1(0), mypos(0), Ltrail(false), Strail(false);
ema1= XAverage(close,20);
mypos = MarketPosition_at_Broker;
mytrailL = Round2Fraction(ema1- TickSize*1.5);
mytrailS = Round2Fraction(ema1 + TickSize*1.5);
condition1 = L > ema1 and L[1] > ema1[1] and L[2] > ema1[2];
condition2 = H < ema1 and H[1] < ema1[1] and H[2] < ema1[2];
If condition1 then Ltrail=true;
If close < ema1 then Ltrail=false;
If condition2 then Strail=true;
If close > ema1 then Strail=false;
If mypos > 0 and Ltrail then begin
sell ("SxT") next bar at mytrailL stop;
ShowLongStop(mytrailL);
end;
If mypos < 0 and Strail then begin
buytocover ("LxT") next bar at mytrailS stop;
ShowShortStop(mytrailS);
end;
If mypos = 0 and mypos[1]<>0 then
Alert("exit via Trailing stop");