- EA's must be coded to recover. If you restart the terminal, crash, power glitch, BSOD, your counts are bogus.
if(OrderClosePrice()>=OrderTakeProfit()) countBuy--;
This will never be true. IF the order has closed you won't find it in the OrderSelect loop. Move the loop to above the open code, then count buys and sells that you don't close.gBuyTicket=OrderSend(_Symbol,OP_BUY,LOTS,Ask,slippage,0,TP,"Market Buy Order Opened",MAGIC,0,clrGreen); countBuy++;
Check your return codes. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Ok.. Mistery solved!
One last question.. How could I select OrderClosingPrice() for each close order then? I should switch to MODE_HISTORY?
Thanks!
leourb_:
Yes.
Ok.. Mistery solved!
One last question.. How could I select OrderClosingPrice() for each close order then? I should switch to MODE_HISTORY?
Thanks!
Thnaks!

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
I have a problem regarding the number of orders that EA can open simultaneously. I set the code as it follows:
It works partially because it opens orders but it does not decrease them! So once reached 5 trades for buys and 5 for sells it does not trade anymore. I have commented inside the loop for orders to see if it effectively loops and "order" variable keeps stack on 1. I cannot figure out why. Could you help me? Thanks!