Each guide pairs equivalent code side by side — same logic, both languages — and ships a free, original, MIT-licensed template you can run today. Demo-test everything: translation bugs are cheaper on demo.
Side-by-side: the core translations — Pine Script v5 → MQL4
| MQL4 / Python / MQL5 (source) | Pine v5 / target |
|---|---|
| Getting an indicator value | |
| |
| Bar-close gating | |
| |
| Persistent variables | |
| |
| Sending an order | |
| |
Translation notes — Pine Script v5 → MQL4
- MQL4 has only orders (no separate positions like MQL5) - pool them with OrderSelect and filter by symbol + magic number.
- 4/5-digit brokers: some old EAs multiply pips by 10 when Digits is 3 or 5. ATR-based stops avoid this - the distance is in price terms already.
- MT4 strategy tester models ticks coarsely ("control points" mode) - verify any converted strategy on every-tick mode or demo before judging it.
Download the templates — Pine Script v5 → MQL4
⬇️ mt4-strategy-template.mq4 (MIT) ⬇️ pine-v5-strategy-template.pine (MIT)
Demo-first, always. Templates are teaching scaffolds with risk guards on by default — never run untested code on a live account.
Upgrading to MT5 later? See the MT4 → MT5 guide; going to TradingView instead: MQL5 → Pine v5.