Download MetaTrader 5
To add comments, please log in or register
What is a social trading? Read the article to find that out!
MetaQuotes Software Corp.
Moderator
177086
MetaQuotes Software Corp. 2014.03.25 14:00 

New article Common Errors in MQL4 Programs and How to Avoid Them has been published:

Some older programs can return errors in the new version of the MQL4 of compiler.

To avoid critical completion of programs, the previous version compiler handled many errors in the runtime environment. For example, division by zero or array out of range are critical errors and usually lead to application crash. Such errors occur only in some states for certain values ​​of variables. Read this article to know how to handle such cases.

The new compiler can detect actual or potential sources of errors and improve code quality.

In this article, we discuss possible errors that can be detected during compilation of old programs and ways to fix them.

  1. Compilation Errors
  2. Runtime Errors
  3. Compiler Warnings

Fixing errors

gbengas2013
47
gbengas2013 2014.04.01 03:09  

this warning ==> "the return value of 'OrderSelect' function should be checked"

is giving me concern. how do i get rid of this warning? what is causing it in the new build of mt4?

cdto2012
5
cdto2012 2014.04.01 06:54  

#property show_inputs

if this is in your code it can prevent your EA from being attached to a chart, I fixed by deleting this and recompiling hopefully the compiler can flag this as an error in the future

Simon Gniadkowski
Moderator
17962
Simon Gniadkowski 2014.04.01 08:27  
ayogbenga2003:

this warning ==> "the return value of 'OrderSelect' function should be checked"

is giving me concern. how do i get rid of this warning? what is causing it in the new build of mt4?

Check the return value . . . that is what it is for: What are Function return values ? How do I use them ?
Alain Verleyen
Moderator
28518
Alain Verleyen 2014.04.01 09:34  
ayogbenga2003:

this warning ==> "the return value of 'OrderSelect' function should be checked"

is giving me concern. how do i get rid of this warning? what is causing it in the new build of mt4?

You double post has been removed.
gaborka1
57
gaborka1 2014.04.02 14:09  
TrailingStop Not work in new mt4!!!
Alain Verleyen
Moderator
28518
Alain Verleyen 2014.04.02 16:13  
gaborka1:
TrailingStop Not work in new mt4!!!

There is no mql4 function specific to trailing stop, and if you are talking about the feature included on MT4 terminal, you are off-topic.

By the way, I just check and MT4 Trailing Stop is working fine for me in build 628.

Mideel
74
Mideel 2014.07.02 17:21  

Hi guys, I want to ask about the new MQL4 tutorial.

Is it fine if I download the MQL5 Book instead because the MQL4 CHM book is not updated and I heard now both MQL5 and MQL4 are quite the same.

Please give me suggestion...

I don't want to read the documentation like that, I want to read the offline version for my tablet.

AutoAbacus
24
AutoAbacus 2014.07.16 16:36  
ayogbenga2003:

this warning ==> "the return value of 'OrderSelect' function should be checked"

is giving me concern. how do i get rid of this warning? what is causing it in the new build of mt4?


It is a warning, as it says. Your EA or script will run without the issue being fixed. Some MetaQuotes examples give this warning when compiled too.

However, such warnings are a good thing, as they tell you that the code is not ideal.

In this case the warning is telling you that the code should be improved to check the return value from the function call in case the call failed. If the call fails then the process, loop, function, whatever, should not try to continue or the next part of the process which tries to use the selected order will fail.

OrderSelect returns true if it worked, or false if it didn't. So your code needs to be something like this:

if (OrderSelect(xxxxx)) {
  // OrderSelect worked - it returned true. Do whatever
}else{
  // OrderSelect failed - it returned false
  return; // or do whatever else is appropriate to the code/logic of your EA
}

or alternatively

if (!OrderSelect(xxxxx))
  // OrderSelect failed - it returned false
  return; // or do whatever else is appropriate to the code/logic of your EA
// OrderSelect worked. do whatever

/
To add comments, please log in or register