Summary: Your EA won‘t load due to compilation errors? This MQL4 guide shows step-by-step how to open the MetaEditor, locate error lines, fix common mistakes like missing semicolons, and recompile successfully.
Step 1: Open MetaEditor from MT4
In your MT4 platform, click the ‘MetaEditor’ icon on the toolbar (or press F4). The MQL4 code editor will open in a new window. Screenshot: MetaEditor icon highlighted on MT4 toolbar.
Step 2: Load Your EA Code
Click ‘File’ → ‘Open’ and navigate to ‘Experts’ folder. Select your EA’s .mq4 file. The code appears in the editor. Screenshot: File menu showing Open option.
Step 3: Click ‘Compile’ and Read Errors
Click the ‘Compile’ button (or press F7). The ‘Errors’ panel at the bottom will list all errors. Each line shows: error description, file name, and line number. Screenshot: Compile button and Errors panel with red text.
Step 4: Fix the Most Common Error – Missing Semicolon
Double-click the first error. The cursor jumps to the problematic line. If you see ‘ ‘;’ expected’, add a semicolon (;) at the end of that line. Re-compile to check. Screenshot: missing semicolon highlighted in code.
Step 5: Fix Wrong Data Type Errors
If error says ‘cannot convert type’, check variable declarations. For example, ‘double’ cannot hold text. Use correct types: ‘int’ for whole numbers, ‘double’ for decimals, ‘string’ for text. Screenshot: data type mismatch error example.
Step 6: Fix Undefined Function or Variable
If error says ‘undeclared identifier’, you are using a function or variable that hasn‘t been defined. Either define it first, or check for spelling mistakes (MQL4 is case-sensitive). Screenshot: undeclared identifier error line.
Step 7: Recompile Until Zero Errors
After each fix, click ‘Compile’ again. Keep fixing until the Errors panel shows ‘0 errors, 0 warnings’. Then close MetaEditor. Your EA is ready to attach to a chart. Screenshot: successful compilation with zero errors.
Reference: MetaQuotes MQL4 Documentation – Compilation and Common Errors.