MetaQuotes development environment

MetaEditor: The Complete Guide to MT4 & MT5 Code Development

MetaEditor is the built-in integrated development environment (IDE) and compiler for MetaTrader 4 and MetaTrader 5. It is used to write, edit, compile, debug, and profile MQL4 and MQL5 programs, including Expert Advisors, custom indicators, scripts, and libraries.

Also covering MetaEditor 4, MetaEditor 5, and MQL code compilation workflows.

Getting started

How to Open MetaEditor in MT5 and MT4

MetaEditor is packaged directly inside MetaTrader installations. You can launch the editor using any of the following five methods.

1

Keyboard Shortcut (F4)

Press F4 at any time while the MetaTrader 4 or MetaTrader 5 terminal is active. Pressing F4 again switches back to MetaTrader.

2

Top Menu Navigation

In the MetaTrader main menu, click Tools and select "MetaQuotes Language Editor".

3

Standard Toolbar Icon

Click the IDE icon (resembling a notebook with a pencil and yellow IDE emblem) located on the main toolbar.

4

Navigator Context Menu

Expand Expert Advisors or Indicators in the Navigator pane, right-click any custom program, and click "Modify" to open its source in MetaEditor.

5

Direct Executable Launch

Launch metaeditor64.exe (for MT5) or metaeditor.exe (for MT4) directly from the terminal installation folder or command line.

Version comparison

MetaEditor 4 vs MetaEditor 5

While both editors share a familiar interface, MetaEditor 5 introduces a 64-bit compilation pipeline, native MQL5 object-oriented programming support, and runtime profiling.

FeatureMetaEditor 4 (MT4)MetaEditor 5 (MT5)
Architecture & Performance32-bit single-process IDE64-bit multi-threaded IDE with fast compilation
Primary LanguageMQL4 (procedural with strict mode)MQL5 (full object-oriented programming, classes, templates)
Debugging & ProfilingBasic visual debugging in testerAdvanced breakpoints, call stack, and tick/time code profiler
Version ControlManual file backup or external GitIntegrated MQL5 Storage cloud repository and Git support
Code Completion (IntelliSense)Standard function auto-completeEnhanced IntelliSense with parameters, struct members, and doc snippets
Project & Multi-File SupportIndividual file compilation with #includeDedicated .mqproj projects, shared include directories, and resource packing

IDE architecture

Key Components of the MetaEditor Workspace

MetaEditor is structured into dedicated modular panels for project navigation, code authoring, compilation diagnostics, and performance analysis.

Navigator Window

Tree structure organising MQL source directories: Experts (EAs), Indicators, Scripts, Include headers, Libraries, and Projects.

Code Editor & IntelliSense

Syntax highlighted editor featuring bracket matching, code folding, auto-formatting, line numbering, and contextual function parameter hints.

Built-in MQL Reference (F1)

Offline documentation accessible by placing the cursor on any MQL keyword or function and pressing F1, providing syntax, signatures, and code examples.

Toolbox & Errors Panel

Displays compilation messages, error codes, line numbers, search results, and MQL5 Storage repository sync status.

Debugger & Call Stack

Set breakpoints in source code, step through execution line by line, inspect local variables, and monitor call stack frames in real time.

Performance Profiler (ME5)

Measures execution speed and function call frequencies across historical price data, pinpointing algorithmic bottlenecks.

Step-by-step guide

MetaEditor 5 Tutorial: From New Project to Execution

Follow this five-step walkthrough to create, code, compile, and execute your first automated program in MetaTrader 5.

1

Open MetaEditor and Launch MQL Wizard

Press F4 in MetaTrader to launch MetaEditor. Click "New" (or Ctrl+N) to open the MQL Wizard, which generates boilerplate structure.

2

Select Program Type

Choose whether to create an Expert Advisor (automated trading), Custom Indicator (chart visualization), Script (single-run utility), or Include file.

3

Define Inputs and Event Handlers

Specify input parameters (such as lot size or moving average period) and select event handlers (OnInit, OnTick, OnTimer, OnDeinit).

4

Write Trading Logic and Compile (F7)

Add your trading calculations inside OnTick(). Press F7 to compile. Inspect the Errors tab to verify 0 errors and 0 warnings.

5

Execute on MetaTrader Chart

Switch back to MetaTrader (F4). Locate your program under Navigator -> Expert Advisors and drag it onto an active price chart.

Common MetaEditor Compilation Errors & Fixes

When compiling in MetaEditor with F7, compiler errors appear in the Toolbox panel. Here is how to resolve the most common diagnostic errors.

undeclared identifier '...'

Root Cause

Variable or function name is misspelled or used before being declared in scope.

Solution

Declare the variable type (such as double, int, or string) before usage, or check header includes.

implicit conversion from '...' to '...'

Root Cause

Assigning incompatible data types without explicit type casting (such as string to number).

Solution

Use explicit conversion functions like StringToDouble(), DoubleToString(), or IntegerToString().

array out of range

Root Cause

Accessing an array index that exceeds its allocated element size or history buffer limit.

Solution

Verify ArraySize() or use ArrayResize(), and check buffer index boundaries inside calculation loops.

unresolved function call '...'

Root Cause

Calling a function whose declaration or library header is missing from the file.

Solution

Verify #include directives and ensure required .mqh header files reside in the MQL4/Include or MQL5/Include directory.

Pineify AI Coding Agents

Draft Clean MQL Code Before Opening MetaEditor

MetaEditor is your compiler and local runtime linker. Pineify MQL4 and MQL5 AI Coding Agents assist by drafting complete, syntax-checked single-file source code from plain English specifications.

Recommended 4-Step Development Cycle

  1. 1. Describe trading rules and indicators in plain English in Pineify.
  2. 2. Review the generated single-file .mq4 or .mq5 artifact and syntax diagnostics.
  3. 3. Copy the clean code into MetaEditor and press F7 to compile.
  4. 4. Backtest the compiled EA in the MetaTrader Strategy Tester.
Static checks do not guarantee market profitability. Always test thoroughly on demo accounts before live trading.

Official Sources & Documentation

This page provides technical software development and educational reference material, not financial or investment advice. Always test trading algorithms in a demo environment before connecting to live broker accounts.

Frequently Asked Questions