I cannot place a correct order using my function and the server returns a code not defined in
2010.02.04 09:38:45 CheckSymbolInfo (EURUSD,H1) PlaceMarketOrder() return code: 10027
What does this 100027 code mean and could you help to figure out what is wrong with my code?
bool PlaceMarketOrder(double val)
Request.volume = NormalizeDouble(MathAbs(val),2);
Request.type = ORDER_TYPE_SELL;
Request.comment = "Sell "+ DoubleToString(Request.volume)+" "+ _Symbol;
Request.type = ORDER_TYPE_BUY;
Request.comment = "Buy "+ DoubleToString(Request.volume)+" "+ _Symbol;
Request.action = TRADE_ACTION_DEAL;
Request.type_filling = ORDER_FILLING_AON;
Request.price = SymbolInfoDouble(_Symbol, SYMBOL_BID);
Request.symbol = _Symbol;
Request.deviation = 5;
Request.magic = 1;
bool result = OrderSend(Request, Result);
if (result == false) Print("OrderSend failure.");
Alert("PlaceMarketOrder() return code: " + IntegerToString(Result.retcode));
value passed to PlaceMarketOrder is 0.1 or -0.1
Does the code you post work for val=-0.1? This will be an ORDER_TYPE_SELL, which correctly needs the bid price for entry price.
val=0.1 (ORDER_TYPE_BUY) will require
Request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
Also, I think Request.deviation should be set to 50 to allow adequate slippage with a 5 digit broker
Thank you for bid/ask advice. I tried to recompile your FraMa cross EA V1_2 (I only changed LOG to Print) and I get the same error code:
2010.02.08 10:58:05 FraMa cross EA V1_2 (EURUSD,H1) Problem with OrderSend in AdjustPosition(): Unknown retcode 10027 in RetCodeToStr()
My MT5 build number is 244. Can you confirm this EA works properly on the latest build for you?
Yes, just tried it on build 244 and it successfully issued a buy and sell order in a few minutes on an M1 chart. I wouldn't write it in quite the same way now, because the behaviour of OrderSend has changed.
Metaquotes seems very quiet about retcode 10027, which isn't listed.
was overwritten by
I had first and second option under 'Allow AutoTrading' enabled.
I found the meaning of 10027 by displaying MqlTradeResult.comment
2010.02.08 22:37:53 PlaceOrderTest (EURUSD,M1) 10027 AutoTrading disabled by client
Strange that MetaQuotes remained silent.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.