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.
MetaQuotes development environment
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
MetaEditor is packaged directly inside MetaTrader installations. You can launch the editor using any of the following five methods.
Press F4 at any time while the MetaTrader 4 or MetaTrader 5 terminal is active. Pressing F4 again switches back to MetaTrader.
In the MetaTrader main menu, click Tools and select "MetaQuotes Language Editor".
Click the IDE icon (resembling a notebook with a pencil and yellow IDE emblem) located on the main toolbar.
Expand Expert Advisors or Indicators in the Navigator pane, right-click any custom program, and click "Modify" to open its source in MetaEditor.
Launch metaeditor64.exe (for MT5) or metaeditor.exe (for MT4) directly from the terminal installation folder or command line.
Version comparison
While both editors share a familiar interface, MetaEditor 5 introduces a 64-bit compilation pipeline, native MQL5 object-oriented programming support, and runtime profiling.
| Feature | MetaEditor 4 (MT4) | MetaEditor 5 (MT5) |
|---|---|---|
| Architecture & Performance | 32-bit single-process IDE | 64-bit multi-threaded IDE with fast compilation |
| Primary Language | MQL4 (procedural with strict mode) | MQL5 (full object-oriented programming, classes, templates) |
| Debugging & Profiling | Basic visual debugging in tester | Advanced breakpoints, call stack, and tick/time code profiler |
| Version Control | Manual file backup or external Git | Integrated MQL5 Storage cloud repository and Git support |
| Code Completion (IntelliSense) | Standard function auto-complete | Enhanced IntelliSense with parameters, struct members, and doc snippets |
| Project & Multi-File Support | Individual file compilation with #include | Dedicated .mqproj projects, shared include directories, and resource packing |
IDE architecture
MetaEditor is structured into dedicated modular panels for project navigation, code authoring, compilation diagnostics, and performance analysis.
Tree structure organising MQL source directories: Experts (EAs), Indicators, Scripts, Include headers, Libraries, and Projects.
Syntax highlighted editor featuring bracket matching, code folding, auto-formatting, line numbering, and contextual function parameter hints.
Offline documentation accessible by placing the cursor on any MQL keyword or function and pressing F1, providing syntax, signatures, and code examples.
Displays compilation messages, error codes, line numbers, search results, and MQL5 Storage repository sync status.
Set breakpoints in source code, step through execution line by line, inspect local variables, and monitor call stack frames in real time.
Measures execution speed and function call frequencies across historical price data, pinpointing algorithmic bottlenecks.
Step-by-step guide
Follow this five-step walkthrough to create, code, compile, and execute your first automated program in MetaTrader 5.
Press F4 in MetaTrader to launch MetaEditor. Click "New" (or Ctrl+N) to open the MQL Wizard, which generates boilerplate structure.
Choose whether to create an Expert Advisor (automated trading), Custom Indicator (chart visualization), Script (single-run utility), or Include file.
Specify input parameters (such as lot size or moving average period) and select event handlers (OnInit, OnTick, OnTimer, OnDeinit).
Add your trading calculations inside OnTick(). Press F7 to compile. Inspect the Errors tab to verify 0 errors and 0 warnings.
Switch back to MetaTrader (F4). Locate your program under Navigator -> Expert Advisors and drag it onto an active price chart.
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 rangeRoot 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
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
Generate and revise editable MQL5 Expert Advisors, custom indicators, and scripts.
Create single-file MT4 Expert Advisors and indicators from natural language prompts.
Automate lot sizing, trailing stops, break-even, and partial exits on MT4 and MT5.
Browse MetaTrader 5 code tutorials, indicator guides, and testing frameworks.
Triage and resolve common MetaEditor compiler, runtime, and trade server errors.
Understand MT5 broker licensing, hosting architecture, APIs, and infrastructure scope.
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.