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).
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.