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.*
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.