MT4 vs MT5: Which Platform for Your EA?
MetaTrader 4 (released 2005) and MetaTrader 5 (released 2010) are both popular trading platforms, but they have significant differences for EA development.
Core Differences Comparison Table
| Feature | MT4 | MT5 |
|---------|-----|-----|
| Release Year | 2005 | 2010 |
| Language | MQL4 | MQL5 |
| Timeframes | 9 | 21 |
| Order Types | 2 (market, pending) | 4 (market, pending, stop, limit) |
| Execution Mode | Single-threaded | Multi-threaded |
| Built-in Indicators | 30 | 38 |
| Economic Calendar | No | Yes |
| Partial Order Fill | No | Yes |
| Backtesting Type | Single-currency | Multi-currency |
Key MQL4 vs MQL5 Syntax Differences
1. Main Function Changes
MQL4:
```mql4
int start() { return(0); }
int init() { return(0); }
int deinit() { return(0); }
```
MQL5:
```mql5
int OnTick() { return(0); }
int OnInit() { return(0); }
void OnDeinit(const int reason) { }
```
2. Order Handling Difference
MQL4 (OrderSelect):
```mql4
for(int i=0; i
if(OrderSymbol()==Symbol()) {
// process order
}
}
```
MQL5 (PositionSelect):
```mql5
for(int i=0; i
PositionSelectByTicket(ticket);
if(PositionGetString(POSITION_SYMBOL)==Symbol()) {
// process position
}
}
```
3. Indicator Calling Syntax
MQL4:
```mql4
double maValue = iMA(NULL, 0, 14, 0, MODE_SMA, PRICE_CLOSE, 1);
```
MQL5:
```mql5
int maHandle = iMA(_Symbol, _Period, 14, 0, MODE_SMA, PRICE_CLOSE);
double maValue[1];
CopyBuffer(maHandle, 0, 1, 1, maValue);
```
Migration Checklist from MT4 to MT5
Recommendation by Scenario
| Scenario | Recommended Platform |
|----------|---------------------|
| Beginner learning EA basics | MT4 |
| Simple moving average strategies | MT4 |
| Multi-currency backtesting needed | MT5 |
| Hedging required | MT5 |
| Partial order fill needed | MT5 |
| Larger broker selection | MT4 |
Reference:
9. Next Step
Part 3 will explain MetaEditor Complete Usage Guide – Interface introduction, creating EA/indicators/scripts, compiling, debugging, and common error fixes.