This is my code for opening a simple buy trade. I wanted to make more complicated stuff since I know how to do it in MQL4, but in MQL5 I can't even make the simplest buy order.
Does anyone know what's stopping the EA from opening a trade?
The error is 4756.
I am using small XM live account for testing, if it matters.
where's the price?
i tried even with the price, it doesn't work
Hi please see here: https://www.mql5.com/en/search#!keyword=4756
Or you can see here
int EXPERT_MAGIC = 12345; // MagicNumber of the expert //+------------------------------------------------------------------+ //| Opening Buy position | //+------------------------------------------------------------------+ void Buy(string symbol,double lots) { //--- declare and initialize the trade request and result of trade request MqlTradeRequest request={0}; MqlTradeResult result={0}; //--- parameters of request request.action =TRADE_ACTION_DEAL; // type of trade operation request.symbol =symbol; // symbol request.volume =lots; // volume request.type =ORDER_TYPE_BUY; // order type request.price =SymbolInfoDouble(symbol,SYMBOL_ASK); // price for opening request.deviation=5; // allowed deviation from the price request.magic =EXPERT_MAGIC; // MagicNumber of the order //--- send the request if(!OrderSend(request,result)) PrintFormat("OrderSend error %d",GetLastError()); // if unable to send the request, output the error code //--- information about the operation PrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order); } //+------------------------------------------------------------------+
Hi please see here: https://www.mql5.com/en/search#!keyword=4756
Or you can see here
That's what i did later, and it still didn't work. Then i got on my demo mt5 account, and it works there. It seems I can't open trades on a live account with EA?
Does that make sense?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This is my code for opening a simple buy trade. I wanted to make more complicated stuff since I know how to do it in MQL4, but in MQL5 I can't even make the simplest buy order.
Does anyone know what's stopping the EA from opening a trade?
The error is 4756.
I am using small XM live account for testing, if it matters.