OPEN-SOURCE SCRIPT
KCP Support & Resistance [Dr.K.C.PRAKASH]

ChatGPT said:
This indicator “KCP Support & Resistance [Dr.K.C.PRAKASH]” (Pine Script v5) is a multi-featured support & resistance tool that combines pivots, slope-based channels, Fibonacci options, and SMA200 trend reference.
🔎 Core Concept
The script identifies pivot highs and lows and uses them to draw support and resistance levels on the chart.
It allows you to visualize them in two ways:
Horizontal lines (flat support/resistance at pivot values).
Parallel slope-based lines (trend-adjusted, drawn with slope factor).
⚙️ Settings & Options
Theme
useDark: Switches to a dark-color palette with bright neon-style lines for better visibility on dark charts.
Basic Settings
length: Pivot length (bars used to detect swing high/low).
lookback: How many past pivot points to use for plotting lines.
Slope: Multiplier applied to slope calculations (for slanted trendline-style S/R).
Extend Horizontal Lines Left?: Option to extend horizontal lines to both sides.
Extend Parallel Lines Left?: Same for slope-based lines.
Show/Hide Controls
Show Parallel Lines?: Toggle diagonal support/resistance.
Show Horizontal Lines?: Toggle flat levels.
Show SMA 200 Line?: Toggle long-term SMA(200) reference.
Hide Fibonacci Lines? / Show Fib Trend Line? / Show All Fibonacci Lines?: (reserved for Fib functionality).
Line Colors
Customizable line colors for parallel & horizontal high/low lines.
If Dark Theme is enabled → Uses preset colors:
Electric Blue (Resistance - Parallel Highs)
Neon Green (Support - Parallel Lows)
Deep Red/Pink (Horizontal Highs)
Warm Yellow (Horizontal Lows)
📐 Logic & Calculations
Pivot Detection
Uses ta.pivothigh & ta.pivotlow with length to mark swing points.
Stores them in arrays for drawing multiple levels.
Slope Calculation
Uses covariance/variance of price vs. time (bar_index) to estimate slope.
Multiplied by Slope factor.
Makes trend-following parallel support/resistance lines possible.
Line Drawing
Parallel lines: Slanted, based on pivot highs/lows + slope.
Horizontal lines: Flat support & resistance levels extended across the chart.
SMA200 Plot
Plots SMA(200) for long-term trend direction.
Colored white if EMA(200) > SMA(200), else yellow (trend bias visual).
📊 What You See on Chart
Support & Resistance drawn dynamically from pivots.
Choice of horizontal (classic S/R) or sloped (trend-following) lines.
Dark theme colors → Electric blue, neon green, deep pink, warm yellow (if enabled).
SMA200 reference line → Helps identify bullish/bearish long-term bias.
Optional Fibonacci lines (future expansion).
This indicator “KCP Support & Resistance [Dr.K.C.PRAKASH]” (Pine Script v5) is a multi-featured support & resistance tool that combines pivots, slope-based channels, Fibonacci options, and SMA200 trend reference.
🔎 Core Concept
The script identifies pivot highs and lows and uses them to draw support and resistance levels on the chart.
It allows you to visualize them in two ways:
Horizontal lines (flat support/resistance at pivot values).
Parallel slope-based lines (trend-adjusted, drawn with slope factor).
⚙️ Settings & Options
Theme
useDark: Switches to a dark-color palette with bright neon-style lines for better visibility on dark charts.
Basic Settings
length: Pivot length (bars used to detect swing high/low).
lookback: How many past pivot points to use for plotting lines.
Slope: Multiplier applied to slope calculations (for slanted trendline-style S/R).
Extend Horizontal Lines Left?: Option to extend horizontal lines to both sides.
Extend Parallel Lines Left?: Same for slope-based lines.
Show/Hide Controls
Show Parallel Lines?: Toggle diagonal support/resistance.
Show Horizontal Lines?: Toggle flat levels.
Show SMA 200 Line?: Toggle long-term SMA(200) reference.
Hide Fibonacci Lines? / Show Fib Trend Line? / Show All Fibonacci Lines?: (reserved for Fib functionality).
Line Colors
Customizable line colors for parallel & horizontal high/low lines.
If Dark Theme is enabled → Uses preset colors:
Electric Blue (Resistance - Parallel Highs)
Neon Green (Support - Parallel Lows)
Deep Red/Pink (Horizontal Highs)
Warm Yellow (Horizontal Lows)
📐 Logic & Calculations
Pivot Detection
Uses ta.pivothigh & ta.pivotlow with length to mark swing points.
Stores them in arrays for drawing multiple levels.
Slope Calculation
Uses covariance/variance of price vs. time (bar_index) to estimate slope.
Multiplied by Slope factor.
Makes trend-following parallel support/resistance lines possible.
Line Drawing
Parallel lines: Slanted, based on pivot highs/lows + slope.
Horizontal lines: Flat support & resistance levels extended across the chart.
SMA200 Plot
Plots SMA(200) for long-term trend direction.
Colored white if EMA(200) > SMA(200), else yellow (trend bias visual).
📊 What You See on Chart
Support & Resistance drawn dynamically from pivots.
Choice of horizontal (classic S/R) or sloped (trend-following) lines.
Dark theme colors → Electric blue, neon green, deep pink, warm yellow (if enabled).
SMA200 reference line → Helps identify bullish/bearish long-term bias.
Optional Fibonacci lines (future expansion).
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.