There are no mind readers here. We can't see your broken code.
whroeder1:
There are no mind readers here. We can't see your broken code.
There are no mind readers here. We can't see your broken code.
Ok, here the code:
int iOOT=OpenedOrders(MagicNumber)+OpenedOrders(MagicNumber+1); if(iOOT==0) { //Openings Print("Send new V2A and V2B..."); int iFool = OrderSend(Symbol(),OP_BUY, Lots,Ask,3,0,0,EA_NAME + "A LONG" ,MagicNumber ,0,clrGreen); RefreshRates(); if(OpenedOrders(MagicNumber)+OpenedOrders(MagicNumber+1)==1) { if(IsTradeContextBusy()==false) { iFool = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,EA_NAME + "B SHORT",MagicNumber+1,0,clrRed); } } if(OpenedOrders(MagicNumber)+OpenedOrders(MagicNumber+1)==1) { Print("ERROR !!!! Safety closure."); CloseAllOrders(MagicNumber); CloseAllOrders(MagicNumber+1); return; } }
OpenedOrders function returns the numbers of opened orders for specific magic number and CloseAllOrders function close all the order with specific magic number.
- Where are your Print statements indicating which call you executed.
- Where do you 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
- You do understand that your code to close all orders will never be called (except if the sell fails?)
- Your log message is meaning less as you don't print the MN or comment
![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
From the 1045 version has made its appearance a serious mistake: When sending in sequence two orders of opposite direction, the second order, sometimes runs in the wrong direction plus without entering the comment and magic number. I find myself in substance to have two buy or two sell instead of one for type, one of which being with MagicNumber 0 is not be managed by my EA which controls only its orders.
I find the following message on the log that is truly terrifying: 2 15: 44: 00,305 sdDynamicGrid v10b EURUSD, M5: open # 50135621 buy (instead of sell) 1.10 EURUSD at 1.07529 ok
In backtest everything works fine. only real occurs, occasionally, this terrible mistake.