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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
🔵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.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
🔵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.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.