| |
 |
2ways system
|
 |
|
|
|
Views:
61 |
| Added: August 25, 2008 |
| |
|
|
|
| This formula has not been rated yet |
| |
| |
email this link
|
| |
| |
| Tags:
MetaTrader, system
|
| |
 |
Code:
/*[[
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
]]*/
defines: Slippage(5),sf(0),risk(12),mm(0);
var: i(0),lotsi(0),dels(0),p1(0),p2(0),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 TotalTrades<1 then {
SetOrder(OP_BUYSTOP,lotsi,Bid+p1*Point,Slippage,Bid-p2*Point,Bid+(p1+TakeProfit)*Point,RED);
SetOrder(OP_SELLSTOP,lotsi,Bid-p2*Point,Slippage,Bid+p1*Point,Bid-(p2+TakeProfit)*Point,RED);
};
If TotalTrades=1 then {
if OrderValue(1,VAL_TYPE)=OP_SELLSTOP or OrderValue(1,VAL_TYPE)=OP_SELL then {
if ord(1,VAL_STOPLOSS)-16*Point > PriceAsk then
SetOrder(OP_BUYSTOP,lotsi,ord(1,VAL_STOPLOSS),Slippage,ord(1,VAL_STOPLOSS)-stoploss*point,ord(1,VAL_STOPLOSS)+TakeProfit*Point,RED);
};
if OrderValue(1,VAL_TYPE)=OP_BUYSTOP or OrderValue(1,VAL_TYPE)=OP_BUY then {
if ord(1,VAL_STOPLOSS)+16*Point < PriceBid then
SetOrder(OP_SELLSTOP,lotsi,ord(1,VAL_STOPLOSS),Slippage,ord(1,VAL_STOPLOSS)+stoploss*point,ord(1,VAL_STOPLOSS)-TakeProfit*Point,RED);
};
};
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 or Ord(i,VAL_TYPE)=OP_BUYSTOP) and dels<>0 then
DeleteOrder(ord(i,VAL_TICKET),red);
};
exit;
Code to difficult? Find somebody to help you with coding here.
Author: Nick Bilak
all systems for MetaTrader
all systems
|