SuperTrend AI Clustering EA
K-Means clustering picks the optimal SuperTrend factor every bar. No more manual tuning.
A production MT5 port of the LuxAlgo SuperTrend AI Pine indicator. Instead of forcing you to guess the best Supertrend factor, the EA runs a grid of factors simultaneously (default 1.0 through 5.0 in 0.5 steps), tracks each factor's rolling performance score, and uses K-Means clustering (k=3) to sort them into Best, Average, and Worst groups every bar. The adaptive factor is the average of the Best cluster — so the system re-tunes itself as volatility and trend-structure shift. An Adaptive Moving Average smoothed by the cluster Performance Index acts as a second-layer entry filter and optional exit trigger. Ships with six preset profiles plus full risk-management scaffolding.
What makes it different.
- Self-tuning Supertrend factor — K-Means clustering with k=3 selects the adaptive multiplier every bar from a configurable factor grid (default 1.0-5.0)
- Performance Index — a confidence score from 0 to ~10 measures how dominantly the Best cluster outperforms; optional minimum-confidence gate blocks trades during uncertainty
- Dual-line visualization — both the adaptive Supertrend line and a Performance-Index-smoothed AMA render on chart, giving a live window into the classifier state
- 40+ input parameters organized into 8 groups — AI Clustering, Entry, Exit, Risk, Money Management, Time, Display, General
- Three stop-loss modes — fixed points, ATR-based, or Supertrend-trailing (tracks the adaptive line itself)
- Optional AMA entry filter + AMA-cross exit — the Adaptive Moving Average becomes a second layer of confirmation tuned by classifier confidence
- Six tuned preset files — M5 scalper, M15 intraday, H1 swing, H4 position (recommended), D1 long-term, XAUUSD specialist
- Comprehensive risk layer — fixed or percent-risk sizing, daily loss circuit-breaker, max-DD kill switch, anti-martingale or martingale scaling, partial close, break-even
- Session + time filter — configurable trading windows with automatic day-of-week gates for FOMC-style event avoidance
- On-chart dashboard — shows cluster centroids, current adaptive factor, Performance Index (decimal and 0-10 scaled), active trend direction, and AMA state
Simulated on $10k starting equity at the stated CAGR. Past performance does not guarantee future results. See risk disclosure.
Every input, documented.
| Parameter | Default | What it controls |
|---|---|---|
| ATRPeriod | 10 | ATR lookback used by every Supertrend instance in the grid. |
| FactorMin | 1.0 | Smallest Supertrend factor in the grid — the most sensitive end. |
| FactorMax | 5.0 | Largest factor in the grid — the slowest, widest-band end. |
| FactorStep | 0.5 | Step size between factors. A step of 0.5 across 1.0-5.0 gives 9 Supertrend instances clustered every bar. |
| PerfAlpha | 10 | Exponential smoothing factor for the per-instance performance score. Higher = longer memory. |
| SelectedCluster | Best | Which K-Means cluster to draw the adaptive factor from: Best, Average, or Worst. |
| MinPerfIndex | 0.0 | Minimum Performance Index required before the EA enters trades. Set to 1.5-3.0 to skip low-confidence regimes. |
| UseAMAFilter | true | Require price above AMA for longs, below for shorts. Cuts trade count ~25% on most symbols. |
| CloseOnAMACross | false | Close positions when price crosses the AMA in the opposite direction. Off by default — the Supertrend trail usually exits first. |
| StopLossMode | Supertrend | Fixed (points), ATR (multiple), or Supertrend (tracks the adaptive line). |
| ATRStopMult | 1.5 | Stop distance as a multiple of ATR when ATR stop mode is active. |
| RiskPerTradePct | 1.0 | Equity % risked per trade. Drop to 0.5 for prop-firm accounts. |
| DailyLossCapPct | 3.0 | Halts trading if equity drops this much in a single trading day. Resets at broker midnight. |
| MaxDDCapPct | 10.0 | Global kill switch — disables the EA for the rest of the evaluation period if equity drawdown exceeds this from peak. |
| MartingaleMode | None | None (default), Martingale (scale up after loss), or Anti-Martingale (scale up after win). |
| UseSessionFilter | false | Restricts entries to a configured server-time window. |
| MaxSpreadPoints | 30 | Blocks entries when spread exceeds this threshold — protects against news-window slippage. |
| MagicNumber | 20260421 | Per-instance identifier for multi-chart operation. |
Full parameter reference in the PDF user guide included with your license.
Frequently asked.
How is this different from a regular Supertrend EA?
Regular Supertrend EAs force you to pick a single factor (usually 3.0). But the optimal factor changes with volatility and trend structure. This EA runs nine factor variants simultaneously, scores each one in real time, and uses K-Means clustering to pick the best one every bar. You never retune — the classifier does it for you.
What is K-Means clustering doing here?
K-Means with k=3 sorts the nine performance scores into three groups: Worst, Average, Best. Centroids are initialized at the 25th, 50th, and 75th percentiles and iterated until they stabilize. The adaptive factor is the average of the factors in the Best cluster — so you always trade the Supertrend variant that has been working best on this symbol and timeframe recently.
What is the Performance Index?
A score from 0 to roughly 10 measuring how confidently the Best cluster is outperforming. Formally: max(avg Best-cluster score, 0) divided by an EMA of absolute price change. High index = strong conviction. The dashboard shows both the raw decimal and a 0-10 scaled version. You can gate entries with MinPerfIndex.
Does it repaint?
No. Cluster assignment, factor selection, and the adaptive Supertrend line are all computed on closed bars. The AMA smooths prior values — it does not look forward.
Which profile should I start with?
H4 Position is the most robust across symbols. If you specifically trade gold, use the XAUUSD Specialist. M5 is only recommended on ECN brokers with tight spreads.
Can I use it on stocks and crypto?
Yes. The algorithm is symbol-agnostic. It runs well on XAUUSD, major FX, indices (US30, NAS100, SPX500, GER40), and crypto (BTCUSD, ETHUSD). The preset files target forex and gold; for indices and crypto, start from the H4 Position preset and raise the ATR stop multiplier by ~30%.
Is this really a LuxAlgo port?
The algorithmic core — K-Means clustering on Supertrend performance scores with a Performance-Index-smoothed AMA — is a faithful MT5/MQL5 port of the LuxAlgo SuperTrend AI Pine indicator. The surrounding EA (orders, risk, sessions, dashboard) is original work. We built it because no production-quality MT5 version existed.
Does it work on MT4?
No. MT5 only.
Ready to run SuperTrend AI Clustering EA?
Lifetime license. All presets included. Direct developer support.