Hi,all.
Now,I have a big problem,what is a big big prolem.
the function of OrderSend() does't useful? I don't know how to use, If someone know ,can write a example,
Thank you.
Hello,
I use the code below to make order but I get error number 10016 (Invalid SL):
bool OrderManagement::OpenPosition(string pSymbol, ENUM_ORDER_TYPE pType, double pVolume, double pStop = 200, double pProfit = 0, string pComment = NULL) { ZeroMemory(request); request.action = TRADE_ACTION_DEAL; request.symbol = pSymbol; request.type = pType; request.sl = pStop; request.tp = pProfit; request.comment = pComment; // Calculate lot size double positionLots = 0; long positionType = WRONG_VALUE; if(PositionSelect(pSymbol) == true) { positionLots = PositionGetDouble(POSITION_VOLUME); positionType = PositionGetInteger(POSITION_TYPE); } if((pType == ORDER_TYPE_BUY && positionType == POSITION_TYPE_SELL) || (pType == ORDER_TYPE_SELL && positionType == POSITION_TYPE_BUY)) { request.volume = pVolume + positionLots; } else request.volume = pVolume; // Order loop int retryCount = 0; int checkCode = 0; do { if(pType == ORDER_TYPE_BUY) request.price = SymbolInfoDouble(pSymbol,SYMBOL_ASK); else if(pType == ORDER_TYPE_SELL) request.price = SymbolInfoDouble(pSymbol,SYMBOL_BID); OrderSend(request,result); checkCode = CheckReturnCode(result.retcode); if(checkCode == CHECK_RETCODE_OK) break; else if(checkCode == CHECK_RETCODE_ERROR) { string errDesc = TradeServerReturnCodeDescription(result.retcode); Alert("Open market order: Error ",result.retcode," - ",errDesc); break; } else { Print("Server error detected, retrying..."); Sleep(RETRY_DELAY); retryCount++; } } while(retryCount < MAX_RETRIES); if(retryCount >= MAX_RETRIES) { string errDesc = TradeServerReturnCodeDescription(result.retcode); Alert("Max retries exceeded: Error ",result.retcode," - ",errDesc); } string orderType = CheckOrderType(pType); string errDesc = TradeServerReturnCodeDescription(result.retcode); Print("Open ",orderType," order #",result.deal,": ",result.retcode," - ",errDesc,", Volume: ",result.volume,", Price: ",result.price,", Bid: ",result.bid,", Ask: ",result.ask); if(checkCode == CHECK_RETCODE_OK) { Comment(orderType," position opened at ",result.price," on ",pSymbol); return(true); } else return(false); }
SL in MqlTradeRequest is a price. Why do you expect 200.0 is a valid price ? Are you trading gold, only ?
I know, I wanted to leave SL in 0 but after this error I thought it shouldn't be 0, so I changed it to an unreachable value.
anyhow, when it was 0 the same error was thrown.
I know, I wanted to leave SL in 0 but after this error I thought it shouldn't be 0, so I changed it to an unreachable value.
anyhow, when it was 0 the same error was thrown.
Error 10016 isn't invalid SL but invalid stops :
10016 | TRADE_RETCODE_INVALID_STOPS | Invalid stops in the request |
So you have to check your TP also. What are the values of SL/TP when you get this error ?
TP:1.7777
SL: 0.0
Price: 1.7774
BUY - GBPAUD.m M1
you trade GBPAUD ,but set the stoploss as 200? or you mean 200pips?
Article Trade Operations in MQL5 - It's Easy, read it carefully and several times. After I red this I have no problems with trade operations in MQL5.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,all.
Now,I have a big problem,what is a big big prolem.
the function of OrderSend() does't useful? I don't know how to use, If someone know ,can write a example,
Thank you.