I need a trailing stop function for the code below. I've checked out several trailing stop functions from metastocktools.com and also the Advanced trailing stop plugin. I am not able to integrate this as a working method for my code using a 5 min. chart forex.
For BUY
c1:=MACD();
c2:=Mov(MACD(),9,E);
LE:=Ref(Cross(c1,c2),-1) AND
C > Ref(C,-1) AND Stoch(12,3)<50;
Tr:=
If(PREV<=0,
If(Ref(LE,-1),O,0),
If(
(H-0.0020)>PREV OR
(L+0.0050)<PREV,-1,PREV)
);
Tr>0 AND Alert(Tr<>0,2)
-----------------------------
For SELL
c1:=MACD();
c2:=Mov(MACD(),9,E);
LE:=Ref(Cross(c1,c2),-1) AND
C > Ref(C,-1) AND Stoch(12,3)<50;
ATRstop:=ATR(10)*2;
Tr:=
If(PREV<=0,
If(Ref(LE,-1),O,0),
If(
(H-0.0020)>PREV OR
(L+0.0050)<PREV OR C<PREV-ATRstop
,-1,PREV));
Tr=-1;
You see, i've been trying something with ATRstop, but it actually doesn't make any sense (C<PREV-ATRstop)
I want a trailing stop that is activated when the first 20 pip pricetarget has been reached OR when a certain amount of timeperiods has passed. That trailing stop should be able to exit the trade when 15% decrease has taken place based on the highest value since the 20 pip pricetarget has been reached. Any help is welcome!
(ps. the buysignal still carries the problem that it keeps plotting buysignals even if the condition isn't true anymore...very weird. The reference to the entryprice for defining the exittarget is working fine though)