/*[[ Name := 2 way orders Author := Copyright c 2003, Nick Bilak beluck[AT]ukr.net Link := http://bilak.port5.com Notes := eur/usd m15 Lots := 1 Stop Loss := 80 Take Profit := 200 Trailing Stop := 80 ]]*/ /* Параметры Stop Loss, Take Profit, Trailing Stop подобраны для eur/usd для других пар следует подбирать другие оптимальные значения тестировалось на eur/usd м15, т.е. почти в реальном времени */ defines: Slippage(5),sf(0),risk(12),mm(0); var: i(0),lotsi(0),dels(0),p1(22),p2(18),Stoplos(0),TrailingSto(0); If FreeMargin<100 then Exit; if mm<>0 then lotsi=Ceil(Balance*risk/10000)/10 else lotsi=Lots; p1=stoploss/2+2; p2=stoploss/2-3; Stoplos=p1+p2; TrailingSto=p1+p2; if mod(time,144000)=0 then If TotalTrades<1 then { SetOrder(OP_BUYSTOP,lotsi,Bid+p1*Point,Slippage,Bid-p2*Point,Bid+(p1+TakeProfit)*Point,RED); //Exit; SetOrder(OP_SELLSTOP,lotsi,Bid-p2*Point,Slippage,Bid+p1*Point,Ask-(p2+TakeProfit)*Point,RED); }; If TotalTrades=1 then if OrderValue(1,VAL_TYPE)=OP_SELLSTOP or OrderValue(1,VAL_TYPE)=OP_BUYSTOP then DeleteOrder(ord(1,VAL_TICKET),red); If TotalTrades=1 then { if OrderValue(1,VAL_TYPE)=OP_SELLSTOP or OrderValue(1,VAL_TYPE)=OP_SELL then { SetOrder(OP_BUYSTOP,lotsi,ord(1,VAL_STOPLOSS),Slippage,ord(1,VAL_STOPLOSS)-stoploss*point,ord(1,VAL_STOPLOSS)+TakeProfit*Point,RED); // exit; }; if OrderValue(1,VAL_TYPE)=OP_BUYSTOP or OrderValue(1,VAL_TYPE)=OP_BUY then { SetOrder(OP_SELLSTOP,lotsi,ord(1,VAL_STOPLOSS),Slippage,ord(1,VAL_STOPLOSS)+stoploss*point,ord(1,VAL_STOPLOSS)-TakeProfit*Point,RED); // exit; }; }; dels=0; for i=1 to TotalTrades begin If Ord(i,VAL_TYPE)=OP_BUY then { If (Bid-Ord(i,VAL_OPENPRICE))>(TrailingSto*Point) then { If Ord(i,VAL_STOPLOSS)<(Bid-TrailingSto*Point) then { ModifyOrder(Ord(i,VAL_TICKET),Ord(i,VAL_OPENPRICE), Bid-TrailingSto*Point,Ord(i,VAL_TAKEPROFIT),Red); dels=Bid-TrailingSto*Point; } else { dels=0; }; }; }; If Ord(i,VAL_TYPE)=OP_SELL then { If (Ord(i,VAL_OPENPRICE)-Ask)>(TrailingSto*Point) then { If Ord(i,VAL_STOPLOSS)>(Ask+TrailingSto*Point) or Ord(i,VAL_STOPLOSS)=0 then { ModifyOrder(Ord(i,VAL_TICKET),Ord(i,VAL_OPENPRICE), Ask+TrailingSto*Point,Ord(i,VAL_TAKEPROFIT),Red); dels=Ask+TrailingSto*Point; } else { dels=0; }; }; }; end; for i=1 to TotalTrades { if Ord(i,VAL_TYPE)=OP_SELLSTOP and dels<>0 then { if dels+15*Point0 then { if dels-15*Point>bid then ModifyOrder(Ord(i,VAL_TICKET),dels+sf*Point,dels-(StopLos-sf)*Point,dels+(TakeProfit+sf)*Point,red); }; }; exit;