OPEN-SOURCE SCRIPT
Gaspard98 - Donchian Channel - Trend Colored - Highs / Lows

> **Donchian Channel — Trend-Colored - Highs / Lows**
>
> This indicator plots a classic **Donchian Channel** (highest high / lowest low over *N* bars) and dynamically colors it based on the **current market structure** — bullish or bearish — making trend direction instantly readable at a glance.
>
> ---
>
> **How it works**
>
> The channel is drawn using:
> - **Upper band** — highest `high` over the chosen period
> - **Lower band** — lowest `low` over the chosen period
> - **Median line** — midpoint of the two bands
>
> Trend state is updated on every bar:
> - A **new swing high** (upper band expanding) flips the state to **bullish** → channel turns green
> - A **new swing low** (lower band expanding) flips the state to **bearish** → channel turns red
> - Bearish signals take **priority** over bullish signals on the same bar
>
> ---
>
> **Settings**
>
> | Parameter | Default | Description |
> |---|---|---|
> | Period | 20 | Lookback length for the channel |
> | Show bands | ✅ | Toggle upper/lower band visibility |
> | Show median | ✅ | Toggle midline visibility |
> | Show background | ✅ | Toggle shaded fill between bands |
> | Bullish color | Green | Color when structure is bullish |
> | Bearish color | Red | Color when structure is bearish |
>
> ---
>
> **Use cases**
> - Quickly identify whether price is making new highs or new lows within any timeframe
> - Use the median as a dynamic support/resistance or trend filter
> - Combine with momentum indicators (RSI, MACD) for confirmation entries
> - Works on any asset and any timeframe
>
> ---
>
> *Based on the original Donchian Channel concept by Richard Donchian. No repainting — all calculations are based on confirmed bar data.*
>
> This indicator plots a classic **Donchian Channel** (highest high / lowest low over *N* bars) and dynamically colors it based on the **current market structure** — bullish or bearish — making trend direction instantly readable at a glance.
>
> ---
>
> **How it works**
>
> The channel is drawn using:
> - **Upper band** — highest `high` over the chosen period
> - **Lower band** — lowest `low` over the chosen period
> - **Median line** — midpoint of the two bands
>
> Trend state is updated on every bar:
> - A **new swing high** (upper band expanding) flips the state to **bullish** → channel turns green
> - A **new swing low** (lower band expanding) flips the state to **bearish** → channel turns red
> - Bearish signals take **priority** over bullish signals on the same bar
>
> ---
>
> **Settings**
>
> | Parameter | Default | Description |
> |---|---|---|
> | Period | 20 | Lookback length for the channel |
> | Show bands | ✅ | Toggle upper/lower band visibility |
> | Show median | ✅ | Toggle midline visibility |
> | Show background | ✅ | Toggle shaded fill between bands |
> | Bullish color | Green | Color when structure is bullish |
> | Bearish color | Red | Color when structure is bearish |
>
> ---
>
> **Use cases**
> - Quickly identify whether price is making new highs or new lows within any timeframe
> - Use the median as a dynamic support/resistance or trend filter
> - Combine with momentum indicators (RSI, MACD) for confirmation entries
> - Works on any asset and any timeframe
>
> ---
>
> *Based on the original Donchian Channel concept by Richard Donchian. No repainting — all calculations are based on confirmed bar data.*
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.