Download MetaTrader 5

Examples: Common Errors in MQL4 Programs and How to Avoid Them

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
190134
MetaQuotes Software Corp.  

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

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 program crash. 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 see how to fix them.

Author: MetaQuotes Software Corp.

MQL4 Comments
16316
MQL4 Comments  

these enum data identifiers are NOT recognized in mql4, even though they are documented in the MQL4 Reference

ENUM_ACCOUNT_STOPOUT_MODE, ENUM_ACCOUNT_TRADE_MODE, ENUM_APPLIED_VOLUME, ENUM_DRAW_TYPE, ENUM_SYMBOL_TRADE_EXECUTION, ENUM_SYMBOL_TRADE_MODE, ENUM_TRADE_RETURN_CODES

for example if I compile a script with this line

Print("MQL_PROGRAM_TYPE = "+MQLInfoInteger(MQL_PROGRAM_TYPE)+" = "+EnumToString((ENUM_PROGRAM_TYPE)MQLInfoInteger(MQL_PROGRAM_TYPE)));

it's all correct and Script prints: MQL_PROGRAM_TYPE = 1 = PROGRAM_SCRIPT

but, if i try to compile this other line

Print("SYMBOL_TRADE_MODE = "+SymbolInfoInteger(Symbol(), SYMBOL_TRADE_MODE)+" = "+EnumToString((ENUM_SYMBOL_TRADE_MODE)SymbolInfoInteger(Symbol(), SYMBOL_TRADE_MODE)));

there are errors! 'NUM_SYMBOL_TRADE_MODE' - undeclared identifier

and so on with 'ENUM_SYMBOL_TRADE_EXECUTION' - undeclared identifier, 'ENUM_ACCOUNT_TRADE_MODE' - undeclared identifier, ..., ...




madmaxbd
24
madmaxbd  

Help me this not working 

 <code removed>

MetaTrader 5 Trading Platform / MetaQuotes Software Corp.
  • www.metaquotes.net
MetaTrader 5 trading platform designed to arrange brokerage services in Forex, CFD, Futures, as well as equity markets
Alain Verleyen
Moderator
33773
Alain Verleyen  
madmaxbd:

Help me this not working 

 <code removed>

Please attach your code as a file, it is too big.
mranda
29
mranda  

Hi, with the new version I am unable to compile my code, receiving the message "expression of 'void' type is illegal" with reference to line 1 column 1 (see attached pictures). The line 1 and column 1 as shown on other attached pict. Any idea what I have to look for?

Thanks for help 

Files:
MSG.PNG 13 kb
prgstart.PNG 6 kb
To add comments, please log in or register