MQL4
Definition
MQL4 is the programming language used to develop expert advisors, indicators, and scripts on MT4. Simpler than MQL5 — procedural syntax, less type-strict, smaller standard library. Legacy commercial EAs are typically MQL4; new commercial EAs ship both MQL4 and MQL5 versions.
In-depth: MQL4
MQL4 occupies the entry-level tier of MetaTrader programming languages. The language was designed for retail traders who learned programming primarily to automate their trading rather than as software engineers, which shaped many of its design decisions.
Key MQL4 language features:
• **Procedural syntax**: traditional functions-and-statements model rather than object-oriented; simpler for non-programmers to learn • **Loose typing**: variables can be assigned values of compatible types without strict type enforcement; reduces boilerplate but increases bug risk • **Built-in trading functions**: OrderSend, OrderClose, OrderSelect, etc., providing direct access to broker operations • **Built-in technical indicators**: iMA, iRSI, iMACD, iBands, etc., for accessing standard indicators without reimplementing them • **Event-driven execution**: OnInit, OnTick, OnTimer, OnDeinit lifecycle functions for EA logic structuring • **Custom indicator support**: programmers can write custom indicators in MQL4 that EAs then consume via iCustom function calls
MQL4 limitations vs MQL5:
• **No object-oriented programming**: complex EA architectures requiring class hierarchies must be expressed procedurally, increasing code complexity • **No multi-threading**: single-threaded execution model limits parallel computation in complex strategies • **Limited standard library**: smaller built-in function library compared to MQL5 • **No native machine learning support**: ML-augmented strategies must call out to external systems or implement primitives manually
For EA buyers, MQL4 source-code visibility (when available) is valuable for auditability. Vendors who provide MQL4 source allow buyers to inspect strategy logic before purchase; vendors who provide only .ex4 compiled binaries require buyer trust in the vendor's claims about the underlying logic. Most premium vendors compile to .ex4 to protect intellectual property; budget vendors sometimes ship source.