You could either do that using a buystop/sellstop that is placed when the first order is placed.
Or are we tallking completely automated EA ?
We are completely talking about automatic ea,not manual trading
Start to write and show the code ....... Then you get the help you want....
&& i wanna to write here, active this trade when the price is under my 1st trade's entry price-200*point)
//+------------------------------------------------------------------+
Please edit your post . . . If you show your code
Looks like First lines mq4 ever written
if(OrdersTotal()==0) { OrderSend(Symbol(),OP_BUY,1,Ask,3,SL,TP,"1234",0123,0,Blue); }
If we talk only about this.... .. if(OrdersTotal()==0)
It will fail placing a trade if you have on your account already an open trade it can be also with pendingtrades only open on your account that it fails
So check opentrades on Symbol() and also MagicNumber().... and count the trades
.
Then also you don't check if the ordersend function succeed...
You place the trade with directly a TP and SL setting nowadays a lot of the brokers are ECN and don't allow to place a BUY or SELL trade with directly SL and TP setting. Also Lotsize hard coded... Make it an input....
Also Slippage hard coded you can make it as input parameter
3 is to low in most cases when you work with a 5 digit broker
Make your EA is gonna work as well on 4 as on 5 digit brokers
"1234", 0123 Tradecomment and magicnumber hard coded you could replace it with a
'extern string TradeComment = "1234"; '
'extern int MagicNumber = 0123; '
See if you can change something in a better way.....
this is just an example~thanks for ur comment
active this trade when the price is under my 1st trade's entry price-200*point,
but i wan to know, how to translate this sentences to MQL4
this is just an example~thanks for ur comment
active this trade when the price is under my 1st trade's entry price-200*point,
but i wan to know, how to translate this sentences to MQL4
Your example is not good
If you wanna write your own EA's then do it good not bad examples we have to help with
How do you check
A The trades of your EA
B If OrderSend succeed....
C EA is working as well on 4 as on 5 digit notation EURUSD
no excusses this is example
Your example is not good
If you wanna write your own EA's then do it good not bad examples we have to help with
How do you check
A The trades of your EA
B If OrderSend succeed....
C EA is working as well on 4 as on 5 digit notation EURUSD
no excusses this is example
sorry boss,ok, now, this is my example,
int start() { //---- if(OrdersTotal()==0) { OrderSend(Symbol(),OP_BUY,1,Ask,50,Ask-300*Point,Ask+300*Point,"1234",0123,0,Blue); } if(OrdersTotal()==1 && i wanna to write here, the price, is at the point under my 1st trade 's price -200* Point) { OrderSend(Symbol(),OP_SELL,1,Bid,50,Bid+300*Point,Bid-300*Point,"2345",0321,0,Red); } //---- return(0); } //+------------------------------------------------------------------+
i don know how to use SRC = = would u mind to teach me ??
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Now, i'm going to write a Hedging EA,
i wanna set that, After i open the 1st trade ( maybe is BUY) price at 1.2300
the second trade will be active if the price at 1.2280, means that, the 1st trade entry price -20 pips,
any one know how to write this out by MQL4?