/*[[ Name := 3x4 trailing stop Author := JF van Niekerk Link := Lots := 1.00 Stop Loss := 12 Take Profit := 10 Trailing Stop := 5 ]]*/ DEFINES: chart(60),lot(1),GMT(3),trade_start(7),trade_end(12),range(60); var:b(0),cnt(0),Long(0),hoog(0),Short(0),orders(0),TP(0),SL(0),TS(0),IncreaseLots(0),Cap(0),i(0); if year <2005 then exit; b=0; if hour=trade_start+GMT and minute<5 and b=0 then { long=high[Highest(MODE_HIGH,7,6)]+1*Point; short=low[lowest(MODE_LOW,7,6)]-1*Point; b=1; }; if long-short>range*Point then exit; if hour>trade_start+GMT and b=1 then b=0; SL=Stoploss*point; TP=TakeProfit*point; TS=TrailingStop*Point; If TotalTrades > 0 Then { for cnt = 1 to TotalTrades Begin If Ord(cnt,VAL_TYPE)=OP_BUYSTOP or Ord(cnt,VAL_TYPE)=OP_SELLSTOP And OrderValue(cnt,VAL_SYMBOL)=Symbol then { If hour>trade_end+1 then { DeleteOrder(OrderValue(cnt,VAL_TICKET),RED); Exit; }; }; end; }; // deleting orders if period != Chart then { Alert("This advisor only works on the ",chart," minute chart"); exit; }; if TotalTrades<1 and b=1 then { SetOrder(OP_BUYSTOP,Lot*2,long,3,Long-SL,Long+TP,blue); SetOrder(OP_BUYSTOP,Lot,Long,3,Long-SL,Long+TP+500*Point,blue); SetOrder(OP_SELLSTOP,Lot*2,short,3,Short+SL,Short-TP,red); SetOrder(OP_SELLSTOP,Lot,Short,3,Short+SL,Short-(TP+500*Point),red); }; For i=1 to TotalTrades { If Ord(i,VAL_TYPE) = OP_BUY And OrderValue(i,VAL_SYMBOL) = Symbol Then { If (Bid-Ord(i,VAL_OPENPRICE)) > (TrailingStop * Point) And (Bid-Ord(i,VAL_OPENPRICE)) > TP Then { If Ord(i,VAL_STOPLOSS) < (Bid - TrailingStop * Point) Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), Bid - TrailingStop * Point, Ord(i,VAL_TAKEPROFIT), White); Exit; }; }; }; If Ord(i,VAL_TYPE) = OP_SELL And OrderValue(i,VAL_SYMBOL) = Symbol Then { If (Ord(i,VAL_OPENPRICE) - Ask) > (TrailingStop * Point) and (Ord(i,VAL_OPENPRICE) - Ask) > TP) Then { If Ord(i,VAL_STOPLOSS) > (Ask + TrailingStop * Point) Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), Ask + TrailingStop * Point, Ord(i,VAL_TAKEPROFIT), Gold); Exit; }; }; }; };