MQL4 and MQL5
Also known as: MQL4, MQL5, MetaQuotes Language
MQL4 and MQL5: MQL4 and MQL5 (MetaQuotes Language) are the programming languages MetaQuotes developed for MetaTrader 4 and MetaTrader 5, used to write Expert Advisors, custom indicators and scripts.
What are MQL4 and MQL5 used for?
Expert Advisors that trade automatically, custom indicators and scripts that carry out one-off tasks in MetaTrader are written in these languages. MQL4 is the language of MetaTrader 4 and MQL5 the language of MetaTrader 5. Programs are written and compiled in MetaEditor, which comes with the platform.
What is the difference between MQL4 and MQL5?
- Platform compatibility: programs compiled from MQL4 (.ex4) run only in MT4, and MQL5 programs (.ex5) only in MT5.
- Trading functions: MT5 handles orders, deals and positions as separate objects, so the trading code of an EA written for MT4 has to be rewritten for MT5.
- Testing: MT5’s Strategy Tester can test several symbols together.
The language an EA is written in says nothing about whether it is profitable; past test results do not guarantee future results.
Example
An EA bought as an .ex4 file cannot be attached to a chart in MT5; an MT5 version written in MQL5 is needed.
Sources
- MQL5 Reference, MetaQuotes
- MQL4 Reference, MetaQuotes
Learn more
- How to Use MetaTrader 4 (MT4): A Beginner's Guide
How to install and use MetaTrader 4 (MT4): logging in, opening trades, pending orders, stop loss and take profit, trailing stops, charts and Expert Advisors.
- How to Use MetaTrader 5 (MT5): A Beginner's Guide
How to install and use MetaTrader 5 (MT5): hedging and netting accounts, opening trades, six pending order types, stop limit orders, trailing stops and EAs.
Related terms
- Expert Advisor
An Expert Advisor (EA) is a program for MetaTrader that can analyse prices and open, manage and close trades automatically according to rules written in MQL4 or MQL5.
- Trailing stop
A trailing stop is a stop loss that moves with the price as a trade goes in your favour. It keeps a set distance from the price and does not move back.