Hi all,
I couldnt find any solution that worked on the following problem:
I added a new "Order function" to my EA, but everytime I get the warning "return value of OrderSend should be checked". The EA doesnt open any trades anymore.
Any ideas where the mistake could be?
Thansk in advance!
Try by changing this line of code:
bool success = OrderSend(request,result);
Whether you use the boolean " success" or not is not so important, the compiler wants to see that you define and assign it.
Try by changing this line of code:
Whether you use the boolean " success" or not is not so important, the compiler wants to see that you define and assign it.
I still get the same Warning and still no trades.... Do u have maybe another idea?
You have to analyze the result to see if the action was successful or not.
//+------------------------------------------------------------------+ //| Opening Buy position | //+------------------------------------------------------------------+ void Buy(int magicnumber,string symbol,double lots,double tp,double sl) { //--- 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 = 3; // allowed deviation from the price request.sl = sl; // Stop Loss of the position request.tp = tp; // Take Profit of the position request.magic = magicnumber; // 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); } //+------------------------------------------------------------------+ //| Opening Sell position | //+------------------------------------------------------------------+ void Sell(int magicnumber,string symbol,double lots,double tp,double sl) { //--- 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_SELL; // order type request.price = SymbolInfoDouble(symbol,SYMBOL_BID); // price for opening request.deviation = 3; // allowed deviation from the price request.sl = sl; // Stop Loss of the position request.tp = tp; // Take Profit of the position request.magic = magicnumber; // 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); } //+------------------------------------------------------------------+
You have to analyze the result to see if the action was successful or not.
Its working now !!
thank you very much and enjoy your day :)
thanks for your quick reply. I really appreciate it!!!
I still get the same Warning and still no trades.... Do u have maybe another idea?
please how can I loop over my positions and select a position to further work it?
The code below works for MQL4 but I need MQL5 code that will do exactly the same thing.
Please I need help on this.
int openOrders = PositionsTotal();
for(int i = 0; i < openOrders; i++)
}
Thanks.
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code properly in a new post.
I have deleted a post as code was not posted properly.
There is no excuse for the person as it was directly after my last post.

- 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,
I couldnt find any solution that worked on the following problem:
I added a new "Order function" to my EA, but everytime I get the warning "return value of OrderSend should be checked". The EA doesnt open any trades anymore.
Any ideas where the mistake could be?
Thansk in advance!