CDP - Counter-Directional-Pivot🎯 CDP - Counter-Directional-Pivot 
 📊 Overview 
The  Counter-Directional-Pivot (CDP)  indicator calculates five critical price levels based on the previous day's OHLC data, specifically designed for multi-timeframe analysis. Unlike standard pivot points, CDP levels are calculated using a unique formula that identifies potential reversal zones where price action often changes direction.
 ⚡ What Makes This Script Original 
This implementation solves several technical challenges that existing pivot indicators face:
 
 🔄  Multi-Timeframe Consistency:  Values remain identical across all timeframes (1m, 5m, 1h, daily) - a common problem with many pivot implementations
 🔒  Intraday Stability:  Uses advanced value-locking technology to prevent the "stepping" effect that occurs when pivot lines shift during the trading session
 💪  Robust Data Handling:  Optimized for both liquid and illiquid stocks with enhanced data synchronization
 
 🧮 CDP Calculation Formula 
The indicator calculates five key levels using the previous day's High (H), Low (L), and Close (C):
 
 CDP = (H + L + C) ÷ 3   (Central Decision Point) 
 AH = 2×CDP + H – 2×L   (Anchor High - Strong Resistance) 
 NH = 2×CDP – L   (Near High - Moderate Resistance) 
 AL = 2×CDP – 2×H + L   (Anchor Low - Strong Support) 
 NL = 2×CDP – H   (Near Low - Moderate Support) 
 
 ✨ Key Features 
 🎨 Visual Elements 
 
 📈  Five Distinct Price Levels:  Each with customizable colors and line styles
 🏷️  Smart Label System:  Shows exact price values for each level
 📋  Optional Value Table:  Displays all levels in an organized table format
 🎯  Clean Chart Display:  Minimal visual clutter while maximizing information
 
 ⚙️ Technical Advantages 
 
 🔐  Session-Locked Values:  Prices are locked at market open, preventing intraday shifts
 🔄  Multi-Timeframe Sync:  Perfect consistency between daily and intraday charts
 ✅  Data Validation:  Built-in checks ensure reliable calculations
 🚀  Performance Optimized:  Efficient code structure for fast loading
 
 💼 Trading Applications 
 
 🔄  Reversal Zones:  AH and AL often act as strong turning points
 💥  Breakout Confirmation:  Price movement beyond these levels signals trend continuation
 🛡️  Risk Management:  Use levels for stop-loss and take-profit placement
 🏗️  Market Structure:  Understand daily ranges and potential price targets
 
 📚 How to Use 
 🚀 Basic Setup 
 
 Add the indicator to your chart (works on any timeframe)
 Customize colors for easy identification of support/resistance zones
 Enable the value table for quick reference of exact price levels
 
 📈 Trading Strategy Examples 
 
 🟢  Long Bias:  Look for bounces at NL or AL levels
 🔴  Short Bias:  Watch for rejections at NH or AH levels  
 💥  Breakout Trading:  Enter positions when price decisively breaks through anchor levels
 ↔️  Range Trading:  Use CDP as the central reference point for range-bound markets
 
 🎯 Advanced Strategy Combinations 
 RSI Integration for Enhanced Signals: 📊 
 
 📉  Oversold Bounces:  Combine RSI below 30 with price touching AL/NL levels for high-probability long entries
 📈  Overbought Rejections:  Look for RSI above 70 with price rejecting AH/NH levels for short opportunities
 🔍  Divergence Confirmation:  When RSI shows bullish divergence at support levels (AL/NL) or bearish divergence at resistance levels (AH/NH), it often signals stronger reversal potential
 ⚡  Momentum Confluence:  RSI crossing 50 while price breaks through CDP can confirm trend direction changes
 
 ⚙️ Configuration Options 
 
 🎨  Line Customization:  Adjust width, style (solid/dashed/dotted), and colors
 👁️  Display Preferences:  Toggle individual levels, labels, and value table
 📍  Table Position:  Place the value table anywhere on your chart
 🔔  Alert System:  Get notifications when price crosses key levels
 
 🔧 Technical Implementation Details 
 🎯 Data Reliability 
The script uses  request.security()  with lookahead settings to ensure historical accuracy while maintaining real-time functionality. The value-locking mechanism prevents the common issue where pivot levels shift during the trading day.
 🔄 Multi-Timeframe Logic 
 
 ⏰  Intraday Charts:  Display previous day's calculated levels as stable horizontal lines
 📅  Daily Charts:  Show current day's levels based on yesterday's OHLC
 🔍  Consistency Check:  All timeframes reference the same source data
 
 🤔 Why CDP vs Standard Pivots? 
Counter-Directional Pivots often provide more accurate reversal points than traditional pivot calculations because they incorporate the relationship between high/low ranges and closing prices more effectively. The formula creates levels that better reflect market psychology and institutional trading behaviors.
 💡 Best Practices 
 
 💧 Use on liquid markets for most reliable results
 📊  RSI Combination:  Add RSI indicator for overbought/oversold confirmation and divergence analysis
 📊 Combine with volume analysis for confirmation
 🔍 Consider multiple timeframe analysis (daily levels on hourly charts)
 📝 Test thoroughly in paper trading before live implementation
 
 💪 Example Market Applications 
 
 NASDAQ:AAPL  AAPL - Tech stock breakouts through AH levels
 $NYSE:SPY SPY - Index trading with CDP range analysis  
 NASDAQ:TSLA  TSLA - Volatile stock reversals at AL/NL levels
 
 
⚠️  This indicator is designed for educational and analytical purposes. Always combine with proper risk management and additional technical analysis tools. 
