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.*
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.