ankit29030:
hello all;
i am practicing mt4 lang and made this ea whic
closes orders if profit lies bw 1.5-2.
closes same order if loss lies bw -2 to -3..
but the code is not working on ecn 55 digit broker...
If your OrderSend() fails so does everything else . . . why don't you check if it has worked or failed ? don't you want to know ? don't you want to know why it failed ? what if youhave more than one order open ? your OrderSelect() fails, and your OrderProfit() will be wrong . . . so will your OrderTicket(), etc, etc.
Read this: What are Function return values ? How do I use them ?
if(OrdersTotal()==0) { OrderSend(Symbol(),0,0.04,Ask,30,0,0); OrderSelect(0,SELECT_BY_POS); if(OrderProfit()>1.5 && OrderProfit()<2) OrderClose(OrderTicket(),OrderLots(),Bid,30); if(OrderProfit()>-2 && OrderProfit()<-3) OrderClose(OrderTicket(),OrderLots(),Bid,30); Print(OrderProfit()); }
- Tick comes in and there is no open orders. (any pair, any EA - not just this one)
- You create one (buy.) Maybe: check your return codes.
- You select the only one in the list. Maybe.
- Since your buy just paid the spread, it will not be in profit by $1.50 to $2.00 (or what ever your account currency is.)
- Likewise not that much negative.
- You print OrderProfit which is bogus if you had closed the order.
- Next tick comes in and there is an open order - nothing else happens.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hello all;
i am practicing mt4 lang and made this ea whic
closes orders if profit lies bw 1.5-2.
closes same order if loss lies bw -2 to -3..
but the code is not working on ecn 55 digit broker...