Permutation Entropy Regime: Free TradingView Indicator

Free TradingView indicator: Open Permutation Entropy Regime on TradingView

Permutation Entropy Regime is a free market-context indicator that estimates whether recent price action is relatively structured or closer to random chop. It does not create buy or sell entries. Instead, it labels the current environment so you can decide whether a trend, breakout or mean-reversion method is appropriate for that context.

Use the indicator free on TradingView

What permutation entropy means here

The indicator uses the Bandt-Pompe idea of permutation entropy. Over a rolling window, it looks at groups of three consecutive closes and records their rank order. There are six possible arrangements. If only a few arrangements occur often, price action is more ordered; if the six arrangements occur with similar frequency, it is more random-walk-like.

The script normalises that result from 0 to 1, then calculates a Predictability score as (1 - normalised entropy) Ă— 100. It also percentile-ranks the current score against recent history, producing a 0-100 Structure Rank that adapts to the symbol and timeframe.

The five market regimes

RegimeWhat it describesPossible response
Structured UpHigh structure rank with positive drift biasConsider trend or breakout rules that already match your plan.
Structured DownHigh structure rank with negative drift biasConsider bearish trend logic or avoid long-only assumptions.
Structured RangeOrdered but sideways behaviourReview range or mean-reversion ideas; avoid assuming direction.
NeutralStructure rank is between the chosen thresholdsReduce conviction and wait for clearer context.
Random / ChopStructure rank is at or below the chop thresholdStand aside, reduce activity or use only a strategy designed for chop.

A label is context, not a prediction. A structured regime can still fail to follow through, and a choppy regime can still produce a sudden directional move.

How to use it with an existing system

  1. Add the indicator to the same symbol and timeframe used by your entry method.
  2. Keep your current entries, stops and risk rules unchanged for the first test.
  3. Record which regimes were active when your normal setups succeeded and failed.
  4. Test a simple filter: trade trend setups only in Structured Up or Structured Down, and compare the sample with unfiltered trades.
  5. Test mean-reversion ideas separately in Structured Range; do not mix the results with trend tests.
  6. Use a sufficiently long Structure Rank Lookback so the percentile is not driven by only a few bars.

Inputs that matter most

Entropy Window controls how many ordinal patterns are used in the histogram. Very small windows react quickly but can be noisy; large windows are slower and smoother. Predictability Smoothing applies an EMA to the raw score. Structure Rank Lookback controls the adaptive percentile window, while Structured Level and Chop Level set the two regime cutoffs.

The drift-bias threshold decides how much directional tilt is needed before the script calls a structured market up or down instead of a structured range. Test these settings on one symbol at a time to avoid tuning the tool to a single lucky period.

Plots, dashboard and alerts

The indicator plots Structure Rank and raw Predictability, with configurable threshold lines. It can shade the pane and colour price bars by regime. The dashboard reports the active regime, Structure Rank, Predictability, normalised entropy, drift bias and the number of bars spent in the current regime.

Five bar-close alert conditions are available: Structured Up, Structured Down, Structured Range, Random / Chop and any regime change. Bar-close alerts reduce intrabar changes, but they do not turn the regime into a trading signal. For alert setup details, read the Pine Script alert-frequency guide.

Repainting and limitations

The calculation uses closed-bar data. The newest forming bar updates until it closes, while historical values remain fixed after a bar closes. There are no higher-timeframe requests or future-looking data access.

  • The fixed embedding dimension of three makes this a deliberately coarse structure estimate.
  • Very small windows can be noisy; very large windows can react too slowly.
  • Repeated equal closes on illiquid or very low-volatility data can bias the pattern count.
  • Higher structure does not guarantee a profitable trend or breakout.

Open Permutation Entropy Regime on TradingView — free

Source and disclosure

The indicator is published as an open-source TradingView script under the Mozilla Public License 2.0. Review the source and test it on your own data. This article is educational and not financial advice.

Leave a Reply

Your email address will not be published. Required fields are marked *