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/).
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.