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).
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.