OPEN-SOURCE SCRIPT
Entropy Momentum Filter [EMF] -FibonacciFlux

Entropy Momentum Filter [EMF]
What it does
Measures directional conviction in price action using Shannon entropy of log returns. Low entropy means strong directional conviction — the market is trending. High entropy means indecision — the market is ranging or chaotic.
How it works
Key Features
How to use
Inputs
Works on all timeframes and instruments. Particularly effective as a regime filter combined with trend-following or mean-reversion strategies.
What it does
Measures directional conviction in price action using Shannon entropy of log returns. Low entropy means strong directional conviction — the market is trending. High entropy means indecision — the market is ranging or chaotic.
How it works
- Entropy Calculation: Builds a histogram of log returns over a rolling lookback window, then computes Shannon entropy H = -sum(p * ln(p))
- Normalization: Divides by ln(N) to produce a 0-1 scale where 0 = perfect order and 1 = maximum randomness
- Color Gradient: Green (low entropy, conviction) → Gray (neutral) → Red (high entropy, indecision)
- Reference Lines: 0.3 low entropy threshold, 0.5 midpoint, 0.7 high entropy threshold
Key Features
- Single clean concept — Shannon entropy applied to price changes
- Normalized 0-1 output — no parameter-dependent interpretation needed
- Built-in alert for conviction spikes (entropy drops below 0.3)
- Only 2 inputs: lookback period and histogram bin count
- Lightweight — minimal computational overhead
How to use
- Conviction filter: Only take trend-following trades when entropy is below 0.5
- Range detection: High entropy (>0.7) suggests avoid trend strategies or switch to mean-reversion
- Conviction spike alert: Built-in alert fires when entropy drops below 0.3 — strong move likely starting
- Combine with directional indicators: Use EMF as a filter on top of your existing signals
Inputs
- Lookback period (default 20) — rolling window for entropy calculation
- Histogram bins (default 10) — granularity of the return distribution
Works on all timeframes and instruments. Particularly effective as a regime filter combined with trend-following or mean-reversion strategies.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
FibonacciFlux: Pushing indicator boundaries. Crafting sophisticated, surprising tools via ambitious R&D.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
FibonacciFlux: Pushing indicator boundaries. Crafting sophisticated, surprising tools via ambitious R&D.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.