OPEN-SOURCE SCRIPT
PDC - Polynomial Direction Channel

PDC - Polynomial Direction Channel is a clean trend-direction tool that aims to see a turn a little earlier. Main timeframe: 1H.
WHAT IT IS
PDC answers one question: which way is the market moving right now? No entries, targets or stops. Just a smooth projection line, an adaptive channel and a clear marker (with price) where the direction flips. It is the companion to CKD (Conformal Kernel Direction), built for faster charts.
HOW IT WORKS
1. Curved projection. On every bar PDC fits a smooth curve (a least-squares parabola, Savitzky-Golay style) through the last 50 closed candles and extends it one bar ahead. A moving average only knows the slope; a curve also sees acceleration, so it notices a turn earlier.
2. Self-calibrating channel (conformal prediction). PDC tracks how far price strayed from its own projection over the last 150 candles and sizes the channel from those errors. Nothing is hand-set: the channel widens in volatile markets and tightens in calm ones.
3. Direction flips. The direction changes only when a candle CLOSES outside the channel on the opposite side. Noise inside the channel is ignored, so sideways markets don't cause constant flipping.
TWO MODES
- Balanced (default): 50-bar curve. Calm, with very few quick reversals.
- Fast: 40-bar curve. Turns a little earlier, with slightly more quick reversals.
Switch anytime in Settings > Direction model > Mode.
WHY 1H
In our comparison across ETH, BTC and SOL on 1H, 4H and 1D, PDC reacted earlier than CKD in most cases and was clearest on 1H, where it was both earlier and calmer on all three pairs. Other timeframes work; for 4H, CKD may suit you better. Settings were chosen on that same data, so treat these as observations, not guarantees.
CHARACTERISTICS
- Direction and flip markers are evaluated on confirmed (closed) candles.
- The projection for each bar uses only previous closes, so the line does not move while a candle forms.
- The channel is calibrated only from errors of earlier, closed candles.
- Uses only the chart's own symbol and timeframe; no higher-timeframe requests.
- Early history depends on how much data the chart loads; after the first flip the direction is consistent.
- Works on any symbol; label prices use the symbol's own tick precision.
HOW TO READ IT
- Cyan = direction up, magenta = direction down (the colour blends smoothly on change).
- UP / DOWN + price = the confirmed candle where the direction flipped and its closing price.
- Wide channel = volatile market, narrow channel = calm market.
- Alerts: Direction up, Direction down, Any flip. Use "Once Per Bar Close".
IMPORTANT
PDC shows direction; it is not a complete trading system and does not guarantee profits. Use it as context together with your own analysis and risk management. Not financial advice.
THANK YOU
A big thank you to everyone who used, liked, commented on and shared CKD. Your engagement and kind words are the reason PDC exists. Feedback and ideas are always welcome in the comments!
(c) 2026 builtbyuba. Licensed under CC BY-NC-SA 4.0 (creativecommons.org/licenses/by-nc-sa/4.0/).
WHAT IT IS
PDC answers one question: which way is the market moving right now? No entries, targets or stops. Just a smooth projection line, an adaptive channel and a clear marker (with price) where the direction flips. It is the companion to CKD (Conformal Kernel Direction), built for faster charts.
HOW IT WORKS
1. Curved projection. On every bar PDC fits a smooth curve (a least-squares parabola, Savitzky-Golay style) through the last 50 closed candles and extends it one bar ahead. A moving average only knows the slope; a curve also sees acceleration, so it notices a turn earlier.
2. Self-calibrating channel (conformal prediction). PDC tracks how far price strayed from its own projection over the last 150 candles and sizes the channel from those errors. Nothing is hand-set: the channel widens in volatile markets and tightens in calm ones.
3. Direction flips. The direction changes only when a candle CLOSES outside the channel on the opposite side. Noise inside the channel is ignored, so sideways markets don't cause constant flipping.
TWO MODES
- Balanced (default): 50-bar curve. Calm, with very few quick reversals.
- Fast: 40-bar curve. Turns a little earlier, with slightly more quick reversals.
Switch anytime in Settings > Direction model > Mode.
WHY 1H
In our comparison across ETH, BTC and SOL on 1H, 4H and 1D, PDC reacted earlier than CKD in most cases and was clearest on 1H, where it was both earlier and calmer on all three pairs. Other timeframes work; for 4H, CKD may suit you better. Settings were chosen on that same data, so treat these as observations, not guarantees.
CHARACTERISTICS
- Direction and flip markers are evaluated on confirmed (closed) candles.
- The projection for each bar uses only previous closes, so the line does not move while a candle forms.
- The channel is calibrated only from errors of earlier, closed candles.
- Uses only the chart's own symbol and timeframe; no higher-timeframe requests.
- Early history depends on how much data the chart loads; after the first flip the direction is consistent.
- Works on any symbol; label prices use the symbol's own tick precision.
HOW TO READ IT
- Cyan = direction up, magenta = direction down (the colour blends smoothly on change).
- UP / DOWN + price = the confirmed candle where the direction flipped and its closing price.
- Wide channel = volatile market, narrow channel = calm market.
- Alerts: Direction up, Direction down, Any flip. Use "Once Per Bar Close".
IMPORTANT
PDC shows direction; it is not a complete trading system and does not guarantee profits. Use it as context together with your own analysis and risk management. Not financial advice.
THANK YOU
A big thank you to everyone who used, liked, commented on and shared CKD. Your engagement and kind words are the reason PDC exists. Feedback and ideas are always welcome in the comments!
(c) 2026 builtbyuba. Licensed under CC BY-NC-SA 4.0 (creativecommons.org/licenses/by-nc-sa/4.0/).
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。