Overview

MetaTrader 5 is a comprehensive trading platform that allows traders to analyze markets, run indicators, and automate strategies. To make automation possible, MetaTrader includes its own programming language — MQL5 (MetaQuotes Language 5). It is a C-like language designed specifically for trading automation, allowing you to build scripts, indicators, and expert advisors (EAs) that execute trades automatically. MQL5 improves upon its predecessor, MQL4, by introducing object-oriented programming and faster execution, making it a robust choice for modern algorithmic trading.

Ad

What You Will Be Able to Do

  • Understand the purpose and structure of the MQL5 programming language.
  • Identify the four main types of MQL5 programs — Script, Indicator, Expert Advisor, and Service.
  • Locate where each program type is stored in the MetaTrader 5 data folder.
  • Launch MetaEditor, the built-in development environment for writing and compiling MQL5 code.

Code Example


//+------------------------------------------------------------------+
//|                                                      Hello.mq5   |
//+------------------------------------------------------------------+
#property version "1.00"
void OnStart()
{
   // Entry point of a simple script
   Print("Hello, MQL5 world!");
}
Ad

Execution Steps

  1. Open MetaEditor from MetaTrader 5 (click the MetaEditor icon or press F4).
  2. Select File → New → Script and name it Hello.
  3. Paste the sample code above into the editor window.
  4. Press F7 to compile. The output file Hello.ex5 will appear under MQL5/Scripts/.
  5. Return to MetaTrader 5, open any chart, and drag the Hello script onto it.
  6. Open the Experts tab at the bottom to view the log message Hello, MQL5 world!.

Key Point

MQL5 programs are executed within the MetaTrader 5 terminal environment. Each program type serves a distinct purpose — Scripts for one-time actions, Indicators for data visualization, Expert Advisors for automated trading, and Services for background tasks. Together, they form a flexible ecosystem that allows traders to automate nearly every aspect of their strategy.

Ad

Next Section

→ Next: What Is MetaEditor