SuperTrend EA for MT5 — No Code
Can I build a SuperTrend EA for MT5 without coding?
Yes. SuperTrend is one of the 47 indicator types in the MT5 Strategy Builder. Add it in Step 3 (Entry rules): Buy when SuperTrend(10, 3) turns up (or Close crosses above the SuperTrend line), and the Sell rule turned around, then exits and risk, then press Get the code in Step 7. If you prefer to hand-code it, compute the bands from ATR in your EA, or read a SuperTrend indicator from the MQL5 Code Base (outline below).
Disclosure: This is an educational guide, not financial advice. Backtest and Demo results do not guarantee live profits.
Related guides: SuperTrend Indicator (academy) · Build EA Without Coding · MA Crossover EA — No Code · Backtest in Strategy Tester · EA Strategy Library
What Is a SuperTrend EA?
A SuperTrend Expert Advisor automates a well-known trend-following rule:
| Signal | Rule (typical) |
|---|---|
| Buy (long) | Price flips above the Supertrend line — SuperTrend turns up / is in an uptrend |
| Sell (short) | Price flips below the line — downtrend |
Supertrend uses ATR to place a dynamic band; the line switches between upper and lower bands when price closes through the band. In MQL5, an EA's logic runs inside OnTick() [1]; MetaTrader 5 has no built-in SuperTrend function, so the EA computes the bands from ATR itself or reads a custom indicator.
Why traders search for this: Clear trend signals without coding ATR math. Most tutorials show Pine or MQL5 code. This guide explains the rule, what it takes in MQL5, and the closest no-code path in AlfaTactix today.
Classic Settings and When It Works
| Setting | Starter value | Notes |
|---|---|---|
| ATR length | 10 | Builder default (1 … 100) |
| Factor | 3 | Builder default (0.1 … 20); higher = wider band, fewer flips |
| Band centre | Median (High + Low) / 2 | Classic formula; some versions use Close |
| Timeframe | M15 or H1 | M5 = more signals; H4 = slower |
| Symbol | EURUSD, GBPUSD | Lower spread helps trend systems |
| Time window | 1–2 closed bars | Has been true for N bars in a row on “is in an uptrend” reduces one-bar noise after a flip |
Works best: Clear trends, liquid sessions (London / New York overlap).
Struggles in: Tight ranges — repeated flips (whipsaw). Mitigate with a Market sessions or Spread limit filter and a stop loss.
For indicator theory and limitations, see SuperTrend Indicator — Settings & Entries.
SuperTrend Logic in MQL5
Without a built-in function, a hand-written EA follows these steps on each new closed bar:
- Create one ATR handle with iATR [2] in OnInit and read the last closed value with CopyBuffer [3].
- Compute the basic bands: mid = (High + Low) / 2; upper = mid + Multiplier × ATR; lower = mid − Multiplier × ATR.
- Ratchet them: in an uptrend the lower band may only rise; in a downtrend the upper band may only fall.
- Flip the direction up when Close breaks above the previous upper band, and down when Close breaks below the previous lower band. A flip is your entry signal.
// OnInit
atrHandle = iATR(_Symbol, PERIOD_M15, 10);
// OnTick, once per new bar
CopyBuffer(atrHandle, 0, 1, 1, atr); // ATR of the last closed bar
double mid = (high[1] + low[1]) / 2.0;
double upper = mid + 3.0 * atr[0];
double lower = mid - 3.0 * atr[0];
// ratchet the bands, then compare close[1] with the previous bands to detect a flip
Alternative: download a SuperTrend indicator from the MQL5 Code Base [4] and read it with iCustom(). Check which buffer holds the line and which holds the direction before you trade on it.
SuperTrend in the Builder
If you want an Expert Advisor without writing MQL5, add the SuperTrend indicator in Step 3. Its parameters are the ATR length (default 10) and the factor (default 3). It has a line and a direction.
| Step | Setting |
|---|---|
| Step 3 — Entry rules | Price crossing above the SuperTrend line for Buy, below it for Sell |
| Step 4 — Filters | Optional session (London / New York) and spread filter |
| Steps 5 and 6 — Exits and risk | ATR-based stop loss, fixed lot or risk % |
For a different trend rule to compare, see MA Crossover EA — No Code. Compare both in the Strategy Tester before choosing.
Trader-Reported Themes (Forums)
Educational summary — not quotes from individuals.
In public threads on r/algotrading and r/Forex, traders often report similar themes about trend-following tools such as Supertrend:
- Whipsaw in ranges — multiple small losses when price chops around the line
- Session matters — filtering to London / New York overlap is a common mitigation
- Backtest vs live — spread and slippage change results; validate on Demo (Backtest an EA in the MT5 Strategy Tester)
- Not a holy grail — combination with risk limits and filters beats “set and forget”
We do not attribute profitability to any influencer “secret” strategy. Validate on your broker and symbol.
Compile and Backtest
- Put your
.mq5inMQL5/Experts(hand-written, or from Get the code in Step 7) and compile (F7) in MetaEditor [5]. - Strategy Tester: Every tick, realistic spread, 6–12 months.
- Demo before live.
Error 10016: Invalid Stops.
Improvements: Filters and Risk
| Problem | Lever |
|---|---|
| Whipsaw in range | Wait 2–3 closed bars after a flip; trade only London / New York; higher Factor |
| Late entries | Lower Factor or shorter ATR length (more noise) |
| Spread cost | Skip entries when the spread is above your limit |
| Stop placement | ATR-based stop sized to the same ATR the bands use |
Next Steps
- SuperTrend Indicator guide — settings and signal logic
- MA Crossover EA — No Code — a different trend rule to compare
- Scalping EA concepts — faster timeframe build
- Build EA Without Coding — full 7-step tour
References: Investopedia — SuperTrend [6] · TradingView SuperTrend [7] · MetaTrader 5 Strategy Tester [8].

