Skip to content
FX Handbook

MQL4 and MQL5

Also known as: MQL4, MQL5, MetaQuotes Language

intermediatePlatforms & ToolsUpdated

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

  1. MQL5 Reference, MetaQuotes
  2. MQL4 Reference, MetaQuotes

Learn more