return value of 'OrderSend' should be checked

 

Hi !

I'm wondering how to do that ...:/ the warning appeared @ the last update

 //--- preparing a request
                           MqlTradeRequest request;
                           ZeroMemory(request);
                           //--- placing an immediate order
                           request.action=TRADE_ACTION_SLTP;
                           //--- instrument
                           request.symbol=Symbol();
                           //--- Stop Loss 
                           request.sl=100;
                           //--- Take Profit is not specified
                           request.tp=0;
               
                           MqlTradeResult result;
                           ZeroMemory(result);
                           MqlTradeCheckResult CheckResult;
                           //--- sending the order
                           if(OrderCheck(request,CheckResult)) { 
                           OrderSend(request,result);
                                                     }
                           
                           else
                             {
                              //--- printing the server response to the log  
                              Print(CheckResult.retcode,"  -error ");
                              Print(request.sl,"  ",LastPrice,"  buy  ");
                              Print(__FUNCTION__,":",CheckResult.comment);
                             }
                             
 
blouf:

Hi !

I'm wondering how to do that ...:/ the warning appeared @ the last update

Note that you must define SL as price and not as relative points, as you are doing.

The exception is value 0, that indicates no SL or no TP.

 
figurelli:

Note that you must define SL as price and not as relative points, as you are doing.

The exception is value 0, that indicates no SL or no TP.

yeah ...  what about the ordercheck ?
 
blouf:

Hi !

I'm wondering how to do that ...:/ the warning appeared @ the last update

just modify as followed...

if(OrderSend(request,result)) {...};

 warning should disappear.

 
blouf:
yeah ...  what about the ordercheck ?

Sorry but your question is not clear to me.

Anyway, if you are meaning that OrderCheck() is so smart to know this SL difference or even convert points in price, I see no way, you must check this for the symbol you are trading. 

 
xhxiang:

just modify as followed...

 warning should disappear.

Right, this will solve the OrderSend() return value check warning, but will not check the return (you need the else condition, as below).

if(OrderSend(request,result)) {...}; else {... return error value check here ...};
 
figurelli:

Right, this will solve the OrderSend() return value check warning, but will not check the return (you need the else condition, as below).

Documentation of Ordersend :

In case of a successful basic check of structures (index checking) returns true. However, this is not a sign of successful execution of a trade operation. For a more detailed description of the function execution result, analyze the fields of result structure.

 
angevoyageur:

Documentation of Ordersend :

Really? I think you misunderstood my point.
 
figurelli:
Really? I think you misunderstood my point.

Not at all. You are right that he has to add an "else" statement. But not in the way your code is showing. Even if OrderSend() return true, you can have a problem with your trading operation.

bool res=OrderSend(request,result);

if(res && (result.retcode=xx || result.retcode=yy ....))
 { Trade operation is ok ...}; 
else 
 {... return error value check here ...};
 
angevoyageur:

Not at all. You are right that he has to add an "else" statement. But not in the way your code is showing. Even if OrderSend() return true, you can have a problem with your trading operation.

Sorry, but I really think you misunderstood my point.

First of all, I said that there was an error at the original code (about SL), and that this is the first and more relevant point to me.

And after, I was trying to say that post below, before mine (and not mine), is not enough to test all OrderSend() return conditions, as looks like you are trying to say.

Forum on trading, automated trading systems and testing trading strategies

return value of 'OrderSend' should be checked

xhxiang, 2014.05.03 04:53

just modify as followed...

if(OrderSend(request,result)) {...};

 warning should disappear.


 
figurelli:

Sorry, but I really think you misunderstood my point.

First of all, I said that there was an error at the original code (about SL), and that this is the first and more relevant point to me.

And after, I was trying to say that post below, before mine (and not mine), is not enough to test all OrderSend() return conditions, as looks like you are trying to say.


Yes, and your answer is not enough either. So my post.
Reason: