OPEN-SOURCE SCRIPT
[CT] Donchian Histogram w/Candle Colors

Donchian Histogram, originally created by RafaelZioni and enhanced with optional price bar coloring, is a momentum-style oscillator that shows where the current close sits inside a dynamic Donchian channel and how that position is evolving over time. The script calculates a rolling high and low over a multi-session lookback period based on your chosen Donchian timeframe, then normalizes the close within that range to create a percentage position between the recent high and low. This normalized value is smoothed with a signal length and plotted as a histogram around a zero line, making it easy to see whether price is pressing toward the upper side of its recent range, the lower side, or oscillating near the middle. Positive values indicate that price is trading closer to the Donchian high, negative values indicate price is closer to the Donchian low, and the magnitude of the histogram reflects how strongly price is favoring one side of the range. The color logic highlights this state visually: stronger positive conditions can be shown in teal, moderate positive conditions in lime, stronger negative conditions in red, and neutral or transitional states in orange. The script also includes an option to color the actual chart candles with the same colors as the histogram, so traders can see Donchian-based pressure directly on the main price chart without constantly looking down at the lower pane. The indicator works on completed bars using standard highest/lowest and moving average functions, so it behaves like a normal oscillator and does not use any lookahead tricks. It is best used as a contextual tool to gauge whether price is pushing to the edges of its recent range or reverting toward balance, and to visually synchronize that information with candle colors when desired.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.