Prism Channel Architecture [JOAT]Prism Channel Architecture
Introduction
Prism Channel Architecture is a dual-channel overlay indicator that layers two mathematically distinct structural frameworks onto your price chart simultaneously: a best-fit Pivot Channel derived from actual price pivot points, and a Linear Regression Channel built from statistical least-squares fitting. Together they create a structural prism through which trend direction, channel quality, and breakout momentum can be evaluated from multiple angles at once.
Most channel tools force you to choose between objectivity and responsiveness. Pivot channels adapt to real market structure but can lag. Regression channels are statistically rigorous but ignore actual swing highs and lows. PCA runs both engines in parallel and highlights the moments when they agree — bull alignment and bear alignment states — as the highest-conviction reads in the system.
Core Concepts
Pivot Channel Fitting
The indicator collects up to a configurable maximum of confirmed pivot highs and pivot lows using TradingView's built-in pivot functions:
float pivHigh = ta.pivothigh(high, pivLeft, pivRight)
float pivLow = ta.pivotlow( low, pivLeft, pivRight)
From those stored pivot arrays, it searches for the best pair of recent pivot highs to fit the upper channel boundary, and the best pair of recent pivot lows to fit the lower channel boundary. The quality score for each candidate pair is computed by checking how many of the recent bars were actually contained below the upper line (or above the lower line) within an ATR tolerance:
for k = 0 to checks - 1
float lineY = linePrice(x2, y2, x1, y1, bar_index - k)
if high <= lineY + atrVal * 0.3
contained += 1
float q = safeDiv(float(contained), float(checks), 0.0)
The pair with the highest containment ratio wins and becomes the drawn channel. This means the upper channel line is always the tightest valid resistance line through recent pivot highs, not an arbitrary parallel projection.
Linear Regression Channel
The regression channel computes a full manual least-squares fit over the lookback window, producing slope, intercept, and residual standard deviation:
float slope = safeDiv(n * sumXY - sumX * sumY, n * sumXSq - sumX * sumX, 0.0)
float intc = safeDiv(sumY - slope * sumX, n, close)
float stdDev = math.sqrt(safeDiv(ssRes, n, 0.0))
The upper and lower bands are drawn at `stdDev × Deviation Multiplier` distance from the regression midline, giving bands that are statistically calibrated to the actual spread of price around the trend. Color shifts from bull to bear when slope changes sign.
Channel Alignment Confluence
The system declares a Bull Alignment when both channels simultaneously agree price is in a bullish position — the regression slope is rising AND price is above the regression midline, AND price is in the upper half of the pivot channel (between the midline and the upper band):
bool lrBull = close > midNow and slope > 0.0
bool pivBull = close > uMid and close < uNow
bool alignBull = lrBull and pivBull
This confluence state is highlighted with a subtle background color — a quiet but meaningful signal that two independent structural frameworks are pointing in the same direction.
ATR-Based Breakout Detection
Breakout signals fire when price moves more than a configurable ATR multiple beyond the prior bar, provided the regression slope confirms direction:
bool brkUp = ta.crossover(close, close + crossTol * atrVal) and lrSlope > 0.0
bool brkDn = ta.crossunder(close, close - crossTol * atrVal) and lrSlope < 0.0
Breakout labels (▲ BRK / ▼ BRK) appear above or below the breakout bar and are alert-enabled.
Features
Pivot Channel — best-fit upper/lower boundaries through recent pivot highs/lows, quality-scored by containment ratio
Regression Channel — least-squares midline with statistically calibrated deviation bands, auto-colored by slope direction
Channel midline — dashed neutral midline bisecting the pivot channel for zone positioning
Bull and Bear Alignment detection — background highlight when both channels agree on direction
ATR-normalized breakout labels — ▲ BRK and ▼ BRK when price breaks out with trend confirmation
Channel Quality score — displayed in dashboard as percentage of recent bars contained
Pivot position classification — Bull Zone (upper half) or Bear Zone (lower half)
Up to 40 pivot highs and 40 pivot lows stored and evaluated
10-bar channel projection extended to the right of the last bar
Dashboard: LR direction, deviation mult, pivot quality, pivot position, alignment, breakout, ATR, pivot count
Alerts for bullish breakout, bearish breakout, bull alignment, and bear alignment
Webhook JSON alert format
Watermark
Input Parameters
Pivot Channel
Pivot Lookback Left — bars to the left required to confirm a pivot high or low (default 10)
Pivot Lookback Right — bars to the right required to confirm a pivot high or low (default 5)
Max Pivots Stored — maximum number of pivot highs and lows held in memory (default 30)
Quality Check Length — number of recent bars used to score channel containment (default 20)
Breakout ATR Mult — ATR multiplier threshold for breakout label generation (default 1.5)
Show Pivot Channel — toggle the pivot channel lines on/off
Regression Channel
Regression Length — bars used in the least-squares fit (default 50)
Deviation Mult — standard deviation multiplier for band width (default 2.0)
Show Regression Channel — toggle the regression channel lines and fill on/off
ATR Settings
ATR Length — lookback for ATR calculation used in breakout detection and containment tolerance (default 14)
Visuals
Bull Color — color for uptrending channels and bullish labels
Bear Color — color for downtrending channels and bearish labels
Neutral Color — color for channel midlines and neutral dashboard text
Show Dashboard — compact structural summary panel
Show Watermark
Show Breakout Labels — toggle ▲ BRK / ▼ BRK label markers
Alerts
Webhook JSON Format — switches alert messages to JSON format for automation pipelines
How to Use
Add PCA to your chart as a main-pane overlay indicator.
Let the chart load enough history so both channels initialize. A warmup period of at least 60 bars is enforced before channels begin drawing.
Use the Regression Channel to assess macro trend direction. If the midline slope is rising and price is above it, the macro environment is bullish.
Use the Pivot Channel to identify the structural support and resistance boundaries formed by actual price pivots. The upper pivot line is the tightest valid resistance. The lower pivot line is the strongest structural support.
Watch for Bull Alignment (cyan background) when both systems agree price is in a bullish structural position. This is the highest-conviction environment for long setups.
Watch for Bear Alignment (red background) for bearish structural setups.
Treat Breakout labels as momentum confirmation signals — they only fire when an ATR-significant price move occurs in the direction of the regression slope.
Check the Pivot Quality score in the dashboard. A quality above 65% means the channels are actively containing price well. Below 40% means the channel fit is loose and breakouts are less reliable.
Indicator Limitations
Pivot channel fitting evaluates only the 8 most recent pivot highs and the 8 most recent pivot lows when searching for the best pair. In very choppy markets with many closely-spaced pivots, the fitted channel may appear narrow or erratic.
The regression channel is recalculated on every bar over a fixed lookback window. It will repaint the past visually as new bars are added — the channel reflects the lookback window ending at the current bar, not a fixed historical period.
Channel quality scores can be artificially high in low-volatility trending conditions where price barely touches the edges of the channel.
Breakout signals require both an ATR threshold move AND a confirming regression slope. In sideways markets the slope condition filters out most breakout candidates, which may lead to missed signals on genuine horizontal range breaks.
Originality Statement
Prism Channel Architecture is an original Pine Script v6 publication. The dual-engine architecture combining a quality-scored best-fit pivot channel with an independently computed least-squares regression channel, and the definition of alignment confluence as agreement between those two distinct structural systems, is an original design. The pivot quality scoring methodology — measuring the containment ratio of recent bars within the candidate channel bounds with ATR tolerance — is an original technique not derived from any existing published indicator.
Disclaimer
This indicator is for educational and informational purposes only. Channels, alignment states, and breakout labels are analytical tools and do not constitute financial advice. Channel boundaries can and will be violated without warning. Always apply proper risk management and never trade solely based on indicator signals.
-Made with passion by jackofalltrades
Indicador Pine Script®






















