OPEN-SOURCE SCRIPT
Triple CTO Background Zones

Title: Triple CTO — Background Zones
Triple CTO — Background Zones paints overbought and oversold background zones using three automatically selected timeframes (one step higher, current, one step lower). Overlay only — no lines, labels, or shapes.
Overview
The Triple CTO — Background Zones indicator computes a Composite Trend Oscillator (CTO) score across three timeframes and paints the chart background when a multi-timeframe overbought or oversold condition is confirmed. It uses one step-higher TF as a trend filter, the current TF as the main filter, and one step-lower TF as signal confirmation. Only background color is drawn to minimize chart clutter.
Key features
- Three automatically-selected timeframes: higher (trend), current (filter), lower (signal).
- CTO score built from multiple smoothed layers (configurable number of layers).
- Multiple smoothing/filter options: PhiSmoother, EMA, DEMA, TEMA, WMA, SMA.
- Hysteresis thresholds (separate entry/exit) to prevent flicker near boundaries.
- Confirmation bars — require N consecutive bars on filter TFs before a zone activates.
- Signal TF must agree in direction to validate the zone.
- Background-only visualization with configurable colors and transparency.
- Efficient: single background paint, no labels/lines; max_bars_back note included.
How it works (concise)
1. Timeframe selection: the script maps the chart timeframe to a standard set (1,3,5,15,30,60,240,D) and picks the neighbouring higher and lower TFs automatically.
2. CTO calculation: the CTO compares progressively smoothed versions of price (close) across many layers. For each layer i the algorithm applies a filter with length i * sp (cluster dispersion) and scores +1 if the previous-smoothed value is greater than the current, otherwise −1. The normalized score is scaled to −100…+100 and optionally post-smoothed.
3. Zone detection:
- Overbought entry when both higher and current TF scores >= Overbought Entry threshold.
- Overbought exit when either score falls below Overbought Exit threshold.
- Analogous rules for oversold using negative thresholds.
- ConfirmBars requires both filter TFs to meet the raw condition for N consecutive bars before entering the latched zone.
- The lower (signal) TF must have score > 0 for overbought or < 0 for oversold to activate the background.
4. Visualization: when an overbought or oversold zone is active, the indicator paints the entire background with the chosen color and transparency.
Inputs (user-facing)
- Visualization: Enable background zones, overbought color, oversold color, transparency (0–100).
- Zone Logic: Overbought entry/exit thresholds, Oversold entry/exit thresholds, Confirm bars (1–10).
- CTO Parameters: Filter type (PhiSmoother, EMA, DEMA, TEMA, WMA, SMA), PhiSmoother phase (ph), Cluster dispersion (sp), Post-smooth length (ps), Number of layers (5–50).
- Note: max_bars_back must be large enough (default 5000) to avoid "not enough bars" errors for large layer/timeframe settings.
Recommended usage
- Use as a clean multi-timeframe background filter to highlight when momentum structure shows extreme consensus across TFs.
- Combine with your own price or indicator entries — the script only signals zone states, not trade entries.
- Increase lenLayers and sp for smoother CTO but expect higher CPU and larger max_bars_back.
- Tweak confirmBars and hysteresis thresholds to reduce noise on shorter timeframes.
Permissions & performance
- Overlay-only indicator; no drawing objects besides background paints.
- Heavy smoothing (many layers, high sp, large ps) increases calculation work and may require raising max_bars_back.
Triple CTO — Background Zones paints overbought and oversold background zones using three automatically selected timeframes (one step higher, current, one step lower). Overlay only — no lines, labels, or shapes.
Overview
The Triple CTO — Background Zones indicator computes a Composite Trend Oscillator (CTO) score across three timeframes and paints the chart background when a multi-timeframe overbought or oversold condition is confirmed. It uses one step-higher TF as a trend filter, the current TF as the main filter, and one step-lower TF as signal confirmation. Only background color is drawn to minimize chart clutter.
Key features
- Three automatically-selected timeframes: higher (trend), current (filter), lower (signal).
- CTO score built from multiple smoothed layers (configurable number of layers).
- Multiple smoothing/filter options: PhiSmoother, EMA, DEMA, TEMA, WMA, SMA.
- Hysteresis thresholds (separate entry/exit) to prevent flicker near boundaries.
- Confirmation bars — require N consecutive bars on filter TFs before a zone activates.
- Signal TF must agree in direction to validate the zone.
- Background-only visualization with configurable colors and transparency.
- Efficient: single background paint, no labels/lines; max_bars_back note included.
How it works (concise)
1. Timeframe selection: the script maps the chart timeframe to a standard set (1,3,5,15,30,60,240,D) and picks the neighbouring higher and lower TFs automatically.
2. CTO calculation: the CTO compares progressively smoothed versions of price (close) across many layers. For each layer i the algorithm applies a filter with length i * sp (cluster dispersion) and scores +1 if the previous-smoothed value is greater than the current, otherwise −1. The normalized score is scaled to −100…+100 and optionally post-smoothed.
3. Zone detection:
- Overbought entry when both higher and current TF scores >= Overbought Entry threshold.
- Overbought exit when either score falls below Overbought Exit threshold.
- Analogous rules for oversold using negative thresholds.
- ConfirmBars requires both filter TFs to meet the raw condition for N consecutive bars before entering the latched zone.
- The lower (signal) TF must have score > 0 for overbought or < 0 for oversold to activate the background.
4. Visualization: when an overbought or oversold zone is active, the indicator paints the entire background with the chosen color and transparency.
Inputs (user-facing)
- Visualization: Enable background zones, overbought color, oversold color, transparency (0–100).
- Zone Logic: Overbought entry/exit thresholds, Oversold entry/exit thresholds, Confirm bars (1–10).
- CTO Parameters: Filter type (PhiSmoother, EMA, DEMA, TEMA, WMA, SMA), PhiSmoother phase (ph), Cluster dispersion (sp), Post-smooth length (ps), Number of layers (5–50).
- Note: max_bars_back must be large enough (default 5000) to avoid "not enough bars" errors for large layer/timeframe settings.
Recommended usage
- Use as a clean multi-timeframe background filter to highlight when momentum structure shows extreme consensus across TFs.
- Combine with your own price or indicator entries — the script only signals zone states, not trade entries.
- Increase lenLayers and sp for smoother CTO but expect higher CPU and larger max_bars_back.
- Tweak confirmBars and hysteresis thresholds to reduce noise on shorter timeframes.
Permissions & performance
- Overlay-only indicator; no drawing objects besides background paints.
- Heavy smoothing (many layers, high sp, large ps) increases calculation work and may require raising max_bars_back.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.