OPEN-SOURCE SCRIPT

[CT] Donchian Histogram w/Candle Colors

627
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.

Exención de responsabilidad

La información y las publicaciones no pretenden ser, ni constituyen, asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.