MT4 error when I compile program

 

Hi, when I try to compile EA I get this error  " Return value of 'OrderSend' needs to be checked". I am trying to create EA based on RSI of two currencies and based on that open trades..

How to resolve this error? 

Regards.

 
Ahmed Hussain:

Hi, when I try to compile EA I get this error  " Return value of 'OrderSend' needs to be checked". I am trying to create EA based on RSI of two currencies and based on that open trades..

How to resolve this error? 

Regards.

IT is not an error, it is a warning.

You resolve it by checking the return value.

If it returns -1 then you know that there was an error, so you print the error (GetLastError())

I will move this to the MQL4 section.

 
Ahmed Hussain: How to resolve this error?

How about doing what the warning says?

Check your return codes, and report your errors. Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
          What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
          Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014

 
Ahmed Hussain:

Hi, when I try to compile EA I get this error  " Return value of 'OrderSend' needs to be checked". I am trying to create EA based on RSI of two currencies and based on that open trades..

How to resolve this error? 

Regards.

bool OrderResult=OrderSend(...);

 
Mehmet Bastem:

bool OrderResult=OrderSend(...);

Is that it?

Where is the error checking?

OrderSend() does not return a bool. Please read my earlier reply and William's.

 
Ahmed Hussain:

Hi, when I try to compile EA I get this error  " Return value of 'OrderSend' needs to be checked". I am trying to create EA based on RSI of two currencies and based on that open trades..

How to resolve this error? 

Regards.

int ticket=0;


//-----

ticket=OrderSend(...);

if(ticket<0)
{
Print("OrderSend error (Direction buy or sell here) error : ",GetLastError());
return;
}
 
Kenneth Parling:

Hi, thanx Kenneth. I want to send you source code of my EA. Please enable direct msg so that I can send you code. Regards.

 
Ahmed Hussain:

Hi, thanx Kenneth. I want to send you source code of my EA. Please enable direct msg so that I can send you code. Regards.

why would i need you source code....? i gave you an example of how to code a correct return value for order send,implement it in your code because i'm not going to do it for you!

Need further help from some one interested in doing it? Post all relevant code right here in your thread

 
Kenneth Parling:

why would i need you source code....? i gave you an example of how to code a correct return value for order send,implement it in your code because i'm not going to do it for you!

Need further help from some one interested in doing it? Post all relevant code right here in your thread

No everything is perfect with the code now just as thanksgiving I want to give this code to you so that you can try it yourself.. Anyways take care

Reason: