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. اقرأ المزيد في شروط الاستخدام.