log in     sign up for free
 
Whenever you get hit, you are very upset emotionally. Most traders try to make it back immediately; they try to play bigger. Whenever you try to get all your losses back at once, you are most often doomed to fail.
Marty Schwartz
 
 
Home
systems (285)
 
 
Special offer: buy MetaStock (try for free)   |   Reuters QuoteCenter Real-Time Data (get a free month)   |   EOD Data
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

2ways system

Formula for: MetaTrader

mql4 expert advisor

 

 

Views:  2022

Added: August 25, 2008
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
This formula has not been rated yet
 

email this link

 
 
Tags: MetaTrader, mql4 expert advisor
 




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

 

View similar (mql4 expert advisor for MetaTrader):

2-EMA expert
2ways system
10 points 3
...
 
 
all formulas for MetaTrader
all formulas

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
PayPalSecure payments by PayPal S4T™ is a part of TAURO EDUCATION NETWORK
 
Privacy note | (c) copyrights systems4trading.com 2006-2009