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.*
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。