OPEN-SOURCE SCRIPT
Choppiness Breakout Filter [forexobroker]

Choppiness Breakout Filter [forexobroker] gates Donchian breakouts behind the Choppiness Index regime so that breaks are only taken when the market is trending, not ranging. The unique angle is that the same Donchian break is treated as a tradable signal in a low-CI trending regime but suppressed as noise when CI is high and the tape is choppy.
🔶 ALGORITHM
1. Compute the Choppiness Index over the CI length: 100 x log10(sum of true range / (highest high - lowest low)) / log10(length). Low CI = directional/trending, high CI = ranging/chop.
2. Classify regime: trending when CI is below the Trend CI threshold; choppy when CI is above the Chop CI threshold.
3. Build a Donchian channel from the prior bar's highest high and lowest low over the breakout lookback.
4. A trend-filtered break is up when regime is trending AND close exceeds the Donchian high; down when trending AND close is below the Donchian low. An up-break sets bias +1, a down-break sets bias -1, and a choppy regime resets bias to flat.
5. Entry timing: in Break-Only mode the signal is the filtered break bar itself; otherwise a close crossover (long) or crossunder (short) of the reclaim EMA in the prevailing bias direction times the entry. Cooldown, position-lock, and bar-close confirmation apply. Non-repainting.
🔶 SIGNAL LOGIC
- Buy: in-session AND ((Break-Only: trending up-break) OR (bias = +1 AND close crosses over the reclaim EMA)) AND position not already long AND cooldown elapsed AND barstate.isconfirmed (then position locks long).
- Sell: in-session AND ((Break-Only: trending down-break) OR (bias = -1 AND close crosses under the reclaim EMA)) AND position not already short AND cooldown elapsed AND barstate.isconfirmed (then position locks short).
- Only fires when the Choppiness Index regime gate is satisfied (breakouts blocked while choppy).
🔶 INPUTS
- Choppiness group: bars the Choppiness Index is computed over; default Choppiness Length 14.
- Trend gate: CI level below which breakouts are enabled; default Trend CI Threshold 45.0.
- Chop gate: CI level above which breakouts are blocked and bias resets; default Chop CI Threshold 61.8.
- Breakout lookback: Donchian length the close must break; default Breakout Lookback 20.
- Volatility reference: ATR length for the dashboard; default ATR Length 14.
- Signal Logic group: entry reclaim EMA, break-only mode, cooldown; default Entry Reclaim EMA 9.
- Cooldown: minimum bars between signals; default Cooldown Bars 5.
- Filters group: optional session restriction and session window; default Restrict to Session off.
- Visual group: Donchian display, dashboard, 3-layer glow, buy/sell colors, dashboard background.
🔶 ALERTS
CBF Buy, CBF Sell, CBF Any Signal, CBF Break Up, CBF Break Down, CBF Trend On, CBF Chop On, CBF EMA Up, CBF EMA Down, CBF CI Trend Cross, CBF Bias Bull, CBF Bias Bear, CBF Webhook JSON.
🔶 LIMITATIONS
- The Choppiness Index needs its full window to stabilise, so the first CI-length bars are warm-up and the regime read is unreliable there.
- The Donchian channel uses the prior bar's extremes, so the broken level is fixed one bar before the break confirms.
- The CI regime gate filters but does not predict; a trending classification describes recent directionality, not future follow-through.
- Default CI thresholds are tuned for liquid instruments; very low or very high volatility regimes may need re-tuning.
- Entries confirm on bar close, so the break or reclaim cross is acknowledged with one-bar lag versus intrabar price.
🔶 ALGORITHM
1. Compute the Choppiness Index over the CI length: 100 x log10(sum of true range / (highest high - lowest low)) / log10(length). Low CI = directional/trending, high CI = ranging/chop.
2. Classify regime: trending when CI is below the Trend CI threshold; choppy when CI is above the Chop CI threshold.
3. Build a Donchian channel from the prior bar's highest high and lowest low over the breakout lookback.
4. A trend-filtered break is up when regime is trending AND close exceeds the Donchian high; down when trending AND close is below the Donchian low. An up-break sets bias +1, a down-break sets bias -1, and a choppy regime resets bias to flat.
5. Entry timing: in Break-Only mode the signal is the filtered break bar itself; otherwise a close crossover (long) or crossunder (short) of the reclaim EMA in the prevailing bias direction times the entry. Cooldown, position-lock, and bar-close confirmation apply. Non-repainting.
🔶 SIGNAL LOGIC
- Buy: in-session AND ((Break-Only: trending up-break) OR (bias = +1 AND close crosses over the reclaim EMA)) AND position not already long AND cooldown elapsed AND barstate.isconfirmed (then position locks long).
- Sell: in-session AND ((Break-Only: trending down-break) OR (bias = -1 AND close crosses under the reclaim EMA)) AND position not already short AND cooldown elapsed AND barstate.isconfirmed (then position locks short).
- Only fires when the Choppiness Index regime gate is satisfied (breakouts blocked while choppy).
🔶 INPUTS
- Choppiness group: bars the Choppiness Index is computed over; default Choppiness Length 14.
- Trend gate: CI level below which breakouts are enabled; default Trend CI Threshold 45.0.
- Chop gate: CI level above which breakouts are blocked and bias resets; default Chop CI Threshold 61.8.
- Breakout lookback: Donchian length the close must break; default Breakout Lookback 20.
- Volatility reference: ATR length for the dashboard; default ATR Length 14.
- Signal Logic group: entry reclaim EMA, break-only mode, cooldown; default Entry Reclaim EMA 9.
- Cooldown: minimum bars between signals; default Cooldown Bars 5.
- Filters group: optional session restriction and session window; default Restrict to Session off.
- Visual group: Donchian display, dashboard, 3-layer glow, buy/sell colors, dashboard background.
🔶 ALERTS
CBF Buy, CBF Sell, CBF Any Signal, CBF Break Up, CBF Break Down, CBF Trend On, CBF Chop On, CBF EMA Up, CBF EMA Down, CBF CI Trend Cross, CBF Bias Bull, CBF Bias Bear, CBF Webhook JSON.
🔶 LIMITATIONS
- The Choppiness Index needs its full window to stabilise, so the first CI-length bars are warm-up and the regime read is unreliable there.
- The Donchian channel uses the prior bar's extremes, so the broken level is fixed one bar before the break confirms.
- The CI regime gate filters but does not predict; a trending classification describes recent directionality, not future follow-through.
- Default CI thresholds are tuned for liquid instruments; very low or very high volatility regimes may need re-tuning.
- Entries confirm on bar close, so the break or reclaim cross is acknowledged with one-bar lag versus intrabar price.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。