One of the hardest work in the computer industry is to place an order with MQL5.
It needs time, you must be passioned, but some day it will happen, I hope.
Was anyone here in the Forum successful ?
MqlTradeRequest EURUSD_Buy;
EURUSD_Buy.action = TRADE_ACTION_DEAL;
EURUSD_Buy.symbol = "EURUSD";
EURUSD_Buy.volume = 1;
EURUSD_Buy.type = ORDER_TYPE_BUY;
EURUSD_Buy.type_filling = ORDER_FILLING_AON;
MqlTradeResult EURUSD_Buy_Result;
OrderSend(EURUSD_Buy,EURUSD_Buy_Result);
Alert(EURUSD_Buy_Result.retcode); // Mistake 10016 (Invalid stops in request)
In the documentation I could read that stoploss / takeprofit values are not neccessary.
The 10016 error is probably because you didn't set the open price. You should really explicitly set all the members of MqlTradeRequest to something, so deviation should be set to something like 50, sl and tp should be set to zero even if you don't want to use them, and I'd also assign a number to magic.
With this values I can place an order:
MqlTick Preis;
MqlTradeRequest EURUSD_Buy;
EURUSD_Buy.action = TRADE_ACTION_DEAL;
EURUSD_Buy.symbol = "EURUSD";
EURUSD_Buy.volume = 1;
EURUSD_Buy.price = 2.00000; //1.48731 at the moment; //Preis.ask: not possible
EURUSD_Buy.deviation = 60000;
EURUSD_Buy.sl = 0;
EURUSD_Buy.tp = 0;
EURUSD_Buy.type = ORDER_TYPE_BUY;
EURUSD_Buy.type_filling = ORDER_FILLING_AON;
MqlTradeResult EURUSD_Buy_Result;
OrderSend(EURUSD_Buy,EURUSD_Buy_Result);
Alert(EURUSD_Buy_Result.retcode); // Return Code 10009: Order done, perfect programming
I take a fantasy price like 2.0 until Preis.ask is working.
MQL5 insert the right ask-price.
Now I know how it runs:
MqlTick Preis;
SymbolInfoTick("EURUSD",Preis);
Alert(Preis.ask);
You must previously use SymbolInfoTick() and then you have access to the variables ask, bid in the structure Preis.
With MqlTradeRequest you have direct access to the variables.
Now I know how it runs:
MqlTick Preis;
SymbolInfoTick("EURUSD",Preis);
Alert(Preis.ask);
You must previously use SymbolInfoTick() and then you have access to the variables ask, bid in the structure Preis.
With MqlTradeRequest you have direct access to the variables.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
One of the hardest work in the computer industry is to place an order with MQL5.
It needs time, you must be passioned, but some day it will happen, I hope.
Was anyone here in the Forum successful ?
In the documentation I could read that stoploss / takeprofit values are not neccessary.