Blog / Strategy
Strategy

Permutation Entropy Regime Trend

Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.

What Is This Strategy?

The Permutation Entropy Regime Trend strategy is a trend-following pullback system that uses permutation entropy — a complexity statistic from information theory — as a filter to decide whether a market is genuinely trending or simply drifting as random noise. Permutation entropy (also called the Bandt-Pompe statistic, after the researchers who introduced it in 2002) measures how ordered or disordered a sequence of prices is, based purely on the rank-order shape of consecutive closes rather than their magnitudes. The strategy pairs this regime filter with a classic, low-risk entry: a with-trend reclaim of an exponential moving average (EMA) baseline.

The core idea is simple to state but statistically motivated. Take the last handful of closing prices and look only at their up/down ordinal pattern — for a triplet of prices there are exactly 3! = 6 possible shapes (rising, falling, peak, valley, and so on). Slide a window across the recent bars, count how often each of the six patterns appears, and compute the Shannon entropy of those frequencies, normalized to a value between 0 and 1. A reading near 1.0 means all patterns are roughly equally likely, which is the fingerprint of a random, choppy path. A lower reading means a few patterns dominate, which historically corresponds to a more ordered, trending path. Because the measure is rank-based, it is invariant to scale and to any monotonic transform, so a single threshold behaves consistently across FX majors, gold, indices, and crypto.

This strategy is best suited as a learning tool for traders who want to understand regime filtering — the practice of only taking a signal when the underlying market state supports it. It is not a shortcut and it is not a guarantee of anything. Instead, it is a clear, self-contained example of how a non-price statistic can be used to refuse trades that a naive pullback system would otherwise take. It was designed with M15–H1 majors and XAUUSD in mind, but the timeframe is never hardcoded — it uses whatever chart it is attached to.

How It Works

The strategy evaluates its logic only on closed bars, so its signals do not repaint. The currently-forming bar is used solely to detect when a new bar has opened. On each new bar, the system recomputes the normalized permutation entropy (PE) of the recent close path and then checks its entry, exit, and management rules.

Regime filter (the gate):

Long entry — the strategy signals a buy when all of the following hold:

Short entry — the strategy signals a sell when the mirror conditions hold:

Cooldown:

Exit and risk management:

permutation entropy MT5 EA
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
PeWindow 40 20 120 Number of closed bars the permutation entropy is measured over. Larger windows smooth the regime read but respond more slowly.
PeThreshold 0.90 0.70 0.98 Ordered-regime ceiling. New trades are only taken when normalized PE is below this value. Lower is stricter (fewer, more-ordered signals).
ExitPeBuffer 0.04 0.00 0.15 Extra entropy above the threshold that forces an open trade to close. Larger values make the regime-exit less trigger-happy.
EmaPeriod 30 10 120 Period of the EMA baseline that the pullback reclaim is measured against.
AtrPeriod 14 7 30 Lookback for the ATR used to size the stop-loss and take-profit.
SlAtrMult 1.8 0.8 4.0 Stop-loss distance as a multiple of ATR.
TpAtrMult 3.0 1.0 6.0 Take-profit distance as a multiple of ATR.
CooldownBars 2 0 20 Bars to wait between entries to avoid churn on borderline reclaims.
Lots 0.10 0.01 2.0 Fixed trade volume in lots.
permutation entropy MT5 EA — MQL5 source code

Recommended Chart Settings

This strategy was designed with M15 to H1 timeframes in mind, on liquid instruments such as EUR/USD, GBP/USD, USD/JPY, and XAUUSD (gold). Because permutation entropy is scale-invariant, the same PeThreshold is intended to be meaningful across these different instruments and across quiet versus volatile regimes — but that does not mean every instrument or timeframe will behave the same way. Trending, liquid markets on intraday timeframes give the entropy gate the cleanest signal to work with; very low-volatility or heavily ranging conditions naturally produce fewer qualifying setups. As with any strategy, results will vary across different market conditions, brokers, and spreads, so always evaluate it on your own data before drawing conclusions.

How to Install on MetaTrader 5

What to Consider Before Using This EA

Strengths of the approach. The permutation entropy gate is a genuinely different way to define "trend" — it reads the geometry of the recent path rather than the size of the moves, so it is robust to scale, outliers, and monotonic transforms. That makes a single threshold behave consistently across instruments, which is unusual for a filter. The pullback-reclaim entry it gates is a well-understood, low-risk pattern, and the regime-invalidation exit gives the system a principled reason to leave a trade early when its core assumption breaks.

Known limitations. Permutation entropy with embedding dimension 3 has only six possible patterns, so it is a coarse view of order — it can misclassify short bursts of structure inside otherwise noisy data, and vice versa. The strategy is by design a filter, so in genuinely choppy markets it may sit out for long stretches and produce very few trades. When it does trade, it inherits the usual weaknesses of moving-average pullback systems: whipsaws around the baseline during transitions, and false reclaims when a trend is actually rolling over. It also trades one position at a time, so it will not scale into a move. Slippage, spread, and swap costs — none of which appear in idealized logic — can meaningfully affect real outcomes, especially on lower timeframes.

Where it may underperform. Expect fewer and lower-quality signals during quiet, mean-reverting ranges (where entropy stays high) and during sharp news-driven spikes (where the ordinal structure changes faster than the window can track). Treat the defaults as a starting point for study, not a finished configuration.

Risk Management Tips

Sound risk management matters far more than any single entry rule. Consider the following general principles as part of your education:

Risk Warning

Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.

Downloads

← Back to Blog