INVITE-ONLY SCRIPT

Chaos Chameleon Risk Reactor [JOAT]

246
# Chaos Chameleon Risk Reactor

Chaos Chameleon Risk Reactor is a Pine Script v6 indicator that fuses pattern-based reversal detection with real-time risk telemetry. It answers two questions on every chart: Is a reversal developing with genuine confluence? And if I take it, what does my risk profile look like right now?

Note: This script is published as an invite-only INDICATOR. It does not generate backtesting results or automated trade execution. Access requires authorization through the script's access control settings.

快照


## Why This Script Merits Invite-Only Protection

This indicator combines multiple analytical dimensions that individually exist as separate tools across the trading community. The value proposition lies in the specific integration methodology and risk-gated scoring system that synthesizes:

  • Pattern intelligence engine detecting 10 candlestick patterns with weighted scoring and configurable thresholds
  • Multi-timeframe confirmation using dual higher timeframes with adjustable weight multipliers
  • Volatility context engine with shock index, compression detection, and squeeze identification
  • Risk architecture calculating VaR proxy, drawdown tracking, heat metrics, and position sizing guidance
  • Signal gating logic requiring pattern score + RR + volume + trend alignment before any signal fires
  • Persistent risk console dashboard displaying 28 real-time metrics across 14 rows


The proprietary elements include the mathematical scoring normalization system, the volatility penalty multipliers during shock conditions, the priority-based label cooldown system preventing overlap, and the multi-module integration logic that prevents conflicting signals. While individual components like EMAs and RSI are standard, their specific combination, the composite risk-gated methodology, and the multi-module integration represent original development work that justifies source code protection.

## How Components Work Together

The indicator's value comes from how its modules interact, not from any single component:

Data Flow:
  • Pattern detection identifies candlestick formations and assigns weighted scores (0-20 scale)
  • Multi-timeframe EMAs establish directional bias across primary and secondary confirmation timeframes
  • Volatility engine assesses shock conditions and compression states, applying penalty multipliers
  • Risk architecture calculates RR ratios, VaR proxy, drawdown, and heat metrics
  • Signal gating requires ALL conditions to align before any entry signal appears
  • Dashboard displays all metrics persistently so risk is never hidden during trade management


Integration Logic:
Each module produces normalized scores that feed into the final signal decision:
  • Pattern score normalized to 0-1 scale against 20-point maximum
  • EMA trend bias applies 1.0x multiplier when aligned, 0.6x when counter-trend
  • RSI momentum applies 1.0x when favorable (>55 bull, <45 bear), 0.8x otherwise
  • Volatility shock applies 0.92x penalty during active shock conditions
  • Final signal requires smoothed score ≥ 0.55, RR ≥ floor, volume confirmed, EMA aligned, no emergency


Why This Integration Matters:
A standard pattern detector might signal "buy" on a hammer while volatility is in shock mode, RR is below minimum, and volume is below baseline. The risk-gated scoring system catches these conflicts and suppresses the signal. This multi-dimensional validation is what separates this indicator from simple pattern detectors that fire on any match.

## Core Functionality

This indicator addresses the challenge of combining reversal detection with persistent risk visibility. Most pattern indicators show entries but leave risk management to guesswork. This script keeps risk math in your field of view throughout the trade.

What This Script Does:

  • Detects 10 candlestick patterns: Hammer, Inverted Hammer, Doji, Bullish/Bearish Engulfing, Morning Star, Evening Star, Piercing Pattern, Dark Cloud Cover, Tweezer Top/Bottom, Continuation Flags
  • Multi-timeframe confirmation using two configurable higher timeframes with weight multipliers
  • RSI divergence detection at confirmed pivot points with configurable pivot span
  • Liquidity sweep identification when price breaks recent extremes then reverses
  • Volatility shock detection combining body-to-ATR ratio with ATR expansion metrics
  • Squeeze/compression detection tracking ATR relative to baseline
  • Risk/Reward calculation using ATR-based stop and target projections
  • VaR proxy calculation using log-return standard deviation with configurable confidence levels
  • Drawdown and heat tracking as exposure proxies with emergency thresholds
  • Position sizing guidance based on account size and risk per trade percentage
  • Adaptive trailing stop that updates as price moves favorably
  • 28-metric risk console dashboard with real-time updates



## Technical Architecture

### Pattern Intelligence Module

The indicator detects 10 candlestick patterns with configurable parameters and weighted scoring:

  • Hammer/Inverted Hammer (weight: 2.0) - Configurable lower shadow ≥ body × 2.5, upper shadow ≤ body × 0.5, body ≤ range × 0.35
  • Doji (weight: 0.5) - Body ≤ range × 0.1 threshold
  • Bullish/Bearish Engulfing (configurable weight, default: 1.5) - Current candle engulfs prior candle body
  • Morning Star/Evening Star (weight: 1.8) - Three-candle reversal with doji middle
  • Piercing Pattern/Dark Cloud Cover (configurable weight, default: 1.1) - Two-candle reversal patterns
  • Tweezer Top/Bottom (configurable weight, default: 1.0) - Equal highs/lows within 15% tolerance
  • Continuation Flags (configurable weight, default: 0.75) - 7-bar high/low with volume confirmation


Each pattern contributes to a cumulative score (0-20 scale) that gets normalized, filtered through trend/volume confirmation, and penalized during volatility shock before any signal appears.

### Multi-Timeframe Confirmation Engine

The script uses two confirmation timeframes to establish directional bias:

  • Primary Confirmation Timeframe (default: 240m/4H) - Higher TF Weight multiplier (default: 1.5x)
  • Secondary Confirmation Timeframe (default: 60m/1H) - Secondary TF Weight multiplier (default: 1.0x)


MTF data uses request.security with lookahead_off to prevent future data leakage. EMA bias from higher timeframes increases pattern score weight. RSI values from both timeframes are fused into a consensus score for composite confidence calculation.

### Volatility Context Engine

  • Shock Index - Combines body-to-ATR ratio (threshold: 1.8x) with ATR expansion relative to baseline (threshold: 1.4x)
  • Compression Lab - Tracks ATR compression ratio (lookback: 21 bars, threshold: 0.85) to identify squeeze conditions
  • Squeeze Detection - Identifies when compression ratio falls below threshold; tracks squeeze initiation and release
  • Volatility Penalty - During active shock, pattern scores receive 0.92x multiplier to reduce false signals


### Risk Architecture

  • Risk/Reward Calculation - Uses ATR × Exit Stop Multiplier (default: 1.2) for stop, ATR × Exit Target Multiplier (default: 2.4) for target
  • VaR Proxy - Log-return standard deviation × Z-score (90%: 1.28, 95%: 1.65, 99%: 2.33) × √horizon days × account size
  • Drawdown Tracking - Percentage decline from highest close over lookback period (default: 200 bars)
  • Heat Metric - ATR% × correlation factor as exposure proxy
  • Emergency Exit - Triggers when drawdown ≥ threshold (default: 12%), heat ≥ threshold (default: 18%), or RR below floor
  • Position Sizing - (Account size × risk%) ÷ dollar risk per share


### Signal Gating Logic

A signal only prints when ALL conditions align:

  • Smoothed pattern score ≥ 0.55 (normalized)
  • Risk/Reward ≥ minimum floor (default: 1.6)
  • Volume > baseline × confirmation multiplier (default: 1.25x)
  • EMA bias confirms direction (Fast EMA vs Slow EMA alignment)
  • No emergency condition active


### Exit Engineering

  • EMA Exit - Price crosses EMA with ATR buffer (default: 0.25 ATR)
  • Time Exit - Configurable bar count since signal (default: 120 bars)
  • Emergency Exit - Drawdown, heat, or RR threshold breach
  • Adaptive Trailing Stop - ATR × trail multiplier (default: 0.85), updates as price moves favorably


### Priority-Based Label System

A cooldown mechanism (default: 8 bars) prevents label overlap. Labels are prioritized:

  • Priority 1: Bull/Bear Signal (Long/Short labels with score)
  • Priority 2: RSI Divergence (RSI Div triangles)
  • Priority 3: Liquidity Sweep (Sweep arrows)
  • Priority 4: Continuation (Flag circles)
  • Priority 5: EMA Exit (EMA Exit crosses)
  • Priority 6: Time Exit (Time Exit diamonds)
  • Priority 7: Burst (compression release diamonds)


Only the highest priority signal displays per cooldown period.


## Visual Elements

Primary Source as Open with Confirmation TimeFrames as 4hr and Daily.

快照

Signal Labels:
  • "Long" / "Short" - Primary entry signals when all gating conditions pass, displays smoothed score (0.00-1.00)


Pattern Markers:
  • "Sweep" (Arrow up/down) - Liquidity sweep detected, price broke recent extreme then reversed
  • "RSI Div" (Triangle up/down) - RSI divergence at confirmed pivot points
  • "Flag" (Circle) - Continuation pattern with volume confirmation
  • "Burst" (Diamond at top) - Compression release, squeeze ending
  • "Pred" (Flag shape) - Predator mode: bull signal + low heat + ADX > 25 + no squeeze
  • "EMA Exit" (Cross) - Price crossed EMA with ATR buffer
  • "Time Exit" (Diamond) - Time-based exit threshold reached
  • "Emergency" (X-cross at top) - Emergency exit conditions active


Camouflage Bands:
EMA-based bands (default: 34-period) with ATR envelopes (default: 1.8x multiplier):
  • Above upper band = bullish tone (lime color)
  • Inside bands = neutral tone (gray color)
  • Below lower band = bearish tone (red color)
  • Transparency adjusts dynamically based on distance from midline


Execution Guides:
  • Stop line (red) - ATR × Exit Stop Multiplier from entry
  • Target line (green) - ATR × Exit Target Multiplier from entry
  • Trail line (yellow) - Adaptive trailing stop, updates as price moves favorably


Bias Bar Coloring:
Bars colored based on net bias (bull score minus bear score). Emergency conditions override with red. Transparency reflects bias magnitude.

Background Tint:
  • Red tint - Emergency exit conditions active
  • Gray tint - Squeeze/compression active



## Risk Console Dashboard

Showing Emergency Bearish Signals, and Burst into Bullish Structure on Chart:

快照

The dashboard displays 28 metrics across 14 rows in a 4-column table (bottom-right position):

Row 1 - Pattern Scores:
  • Bull Score - Current bullish pattern strength (0.00-1.00)
  • Bear Score - Current bearish pattern strength (0.00-1.00)


Row 2 - Volatility & Trend:
  • ATR% - ATR as percentage of price
  • ADX - Average Directional Index strength


Row 3 - Risk/Reward:
  • RR Long - Risk/Reward ratio for long positions
  • RR Short - Risk/Reward ratio for short positions


Row 4 - Exposure Metrics:
  • Drawdown% - Chart-level drawdown from highest close
  • Heat% - Volatility-based exposure proxy


Row 5 - Bias Analysis:
  • Net Bias - Bull score minus bear score
  • Confidence - Level (High/Medium/Developing/Forming) with bias label (Bullish/Bearish/Balanced)


Row 6 - Risk Metrics:
  • VaR - Value at Risk proxy with configured confidence level
  • Shock - Volatility shock status with multiplier (Active/Calm)


Row 7 - Momentum:
  • Slope - Smoothed RSI momentum slope
  • Div / Sweep - Last divergence and sweep events


Row 8-9 - Execution Levels:
  • Stop L / Stop S - Current stop levels for long/short
  • Trail L / Trail S - Adaptive trailing stop levels


Row 10 - Position Sizing:
  • Pos Size L / Pos Size S - Recommended position sizes based on account and risk settings


Row 11 - Exit Status:
  • Emergency - Emergency exit status (ACTIVE/Clear)
  • Time Exit - Time-based exit status (Pending/n/a)


Row 12 - Performance Proxies:
  • Sharpe* - Sharpe ratio proxy (annualized from chart data)
  • Sortino* - Sortino ratio proxy


Row 13 - Additional Metrics:
  • Hit Rate - Win rate proxy from chart data
  • Camouflage - Band position (Above/Inside/Below) + Squeeze status (Coiled/Expansion/Normal) with compression ratio


Proxy Disclaimer: VaR, Sharpe, Sortino, and Hit Rate are derived from chart data with simplified assumptions. They provide context, not audited performance statistics.


## Complete Configuration Reference

Customized Settings with a new Primary Source, and New Risk:
快照

### Trend & Confirmation Group

  • Primary Source (default: close) - Price source for calculations. Options: open, high, low, close, hl2, hlc3, ohlc4, hlcc4
  • Fast EMA Length (default: 21) - Fast exponential moving average period
  • Slow EMA Length (default: 55) - Slow exponential moving average period
  • Confirmation Timeframe (default: 240/4H) - Primary higher timeframe for trend confirmation
  • Higher TF Weight (default: 1.5) - Weight multiplier for primary timeframe signals
  • Secondary Confirmation TF (default: 60/1H) - Secondary timeframe for additional confirmation
  • Secondary TF Weight (default: 1.0) - Weight multiplier for secondary timeframe signals
  • Pattern Score Smoothing (default: 3, range: 1-15) - EMA smoothing applied to pattern scores


### Pattern Intelligence Group

  • Hammer Lower Shadow ≥ Body × (default: 2.5) - Minimum lower shadow to body ratio for hammer detection
  • Hammer Upper Shadow ≤ Body × (default: 0.5) - Maximum upper shadow to body ratio for hammer detection
  • Hammer Body ≤ Range × (default: 0.35) - Maximum body to candle range ratio for hammer detection
  • Doji Body ≤ Range × (default: 0.1) - Maximum body to range ratio for doji detection
  • Engulfing Weight (default: 1.5) - Score weight for engulfing patterns
  • Continuation Pattern Weight (default: 0.75) - Score weight for continuation patterns
  • Piercing / Dark Cloud Weight (default: 1.1) - Score weight for piercing and dark cloud patterns
  • Tweezer Weight (default: 1.0) - Score weight for tweezer patterns
  • Volume Lookback (default: 30) - Bars for volume baseline calculation
  • Volume Confirmation Multiplier (default: 1.25) - Volume must exceed baseline × this value
  • RSI Divergence Pivot Span (default: 5, range: 1-20) - Bars for pivot detection in divergence analysis
  • Show RSI Divergence Markers (default: true) - Toggle RSI divergence labels
  • Highlight Liquidity Sweeps (default: true) - Toggle liquidity sweep detection
  • Liquidity Sweep Lookback (default: 20) - Bars to look back for sweep floor/ceiling


### Risk Architecture Group

  • ATR Length (default: 14) - Period for Average True Range calculation
  • ATR Position Sizing Multiplier (default: 1.5) - Multiplier for ATR-based position sizing
  • Account Size (default: 100,000) - Base currency account size for position sizing
  • Risk Per Trade % (default: 1.0%, range: 0.1-10%) - Percentage of account to risk per trade
  • Correlation Heat Factor (default: 1.0, range: 0.5-3.0) - Multiplier for heat metric calculation
  • VaR Confidence (default: 95%) - Confidence level for VaR calculation. Options: 90%, 95%, 99%
  • VaR Lookback (default: 100, min: 20) - Bars for VaR standard deviation calculation
  • VaR Holding Horizon (default: 1 day, range: 1-10) - Days for VaR projection
  • Drawdown Lookback (default: 200, min: 50) - Bars for drawdown calculation
  • Emergency Drawdown Threshold % (default: 12%, range: 2-50%) - Drawdown level triggering emergency exit
  • Portfolio Heat Threshold % (default: 18%, range: 5-50%) - Heat level triggering emergency exit
  • Minimum Risk/Reward (default: 1.6, min: 0.5) - Minimum RR required for signal generation
  • Performance Lookback (default: 60, range: 20-500) - Bars for Sharpe/Sortino/Hit Rate calculations


### Flow & Volatility Group

  • Shock Index Lookback (default: 20, min: 5) - Bars for shock baseline calculation
  • Shock Sensitivity (default: 1.8) - Body ÷ ATR threshold for shock detection
  • Volatility Shock Threshold (default: 1.4) - ATR ÷ baseline threshold for shock detection
  • Momentum Slope Length (default: 21) - Bars for RSI slope calculation


### Exit Engineering Group

  • Exit Stop ATR × (default: 1.2, min: 0.5) - ATR multiplier for stop placement
  • Exit Target ATR × (default: 2.4, min: 0.5) - ATR multiplier for target placement
  • EMA Exit ATR Buffer (default: 0.25, range: 0-5) - ATR buffer for EMA exit detection
  • Time-Based Exit Bars (default: 120, min: 10) - Bars before time exit triggers
  • Show Adaptive Trailing Guides (default: true) - Toggle trailing stop visualization
  • Trailing Stop ATR × (default: 0.85, range: 0.2-5) - ATR multiplier for trailing stop


### Visualisation Group

  • Show Reversal Labels (default: true) - Toggle main Long/Short signal labels
  • Show Continuation Labels (default: true) - Toggle Flag continuation labels
  • Display Risk Console Table (default: true) - Toggle dashboard visibility
  • Show Execution Bands (default: true) - Toggle stop/target level lines
  • Show Risk Pulse Panel (default: true) - Toggle heat ratio histogram in separate pane
  • Show Pattern Heat Histogram (default: true) - Toggle bull/bear pattern strength histogram in separate pane
  • Bias Bar Coloring (default: true) - Toggle bias-based bar coloring
  • Show Camouflage Bands (default: true) - Toggle EMA envelope bands
  • Show Tactical Markers (default: true) - Toggle Burst/Predator markers
  • Label Cooldown Bars (default: 8, range: 1-50) - Minimum bars between labels to prevent overlap
  • Camouflage EMA Length (default: 34, min: 2) - Period for camouflage band midline
  • Camouflage ATR Multiplier (default: 1.8, min: 0.5) - ATR multiplier for band width
  • Squeeze Lookback (default: 21, min: 5) - Bars for squeeze baseline
  • Squeeze Compression Threshold (default: 0.85, range: 0.1-2.0) - Ratio below which squeeze is active


### Color Customization

  • Bull Skin Color (default: lime) - Primary bullish color for camouflage bands
  • Bear Skin Color (default: red) - Primary bearish color for camouflage bands
  • Neutral Skin Color (default: gray 60%) - Neutral/inside band color
  • Accent Color (default: teal) - Accent for continuation patterns
  • Bull Primary (default: lime) - Bull signal and metric color
  • Bear Primary (default: red) - Bear signal and metric color
  • Neutral Tone (default: gray 75%) - Neutral background tone
  • Pulse Accent (default: aqua) - Heat pulse accent color


## Alert System

The script includes six alert conditions:

  • Bull Signal - Fires when bullish reversal detected with all gating conditions met (pattern score ≥ 0.55, RR ≥ floor, volume confirmed, EMA aligned, no emergency)
  • Bear Signal - Fires when bearish reversal detected with all gating conditions met
  • Long Exit - Fires when exit logic triggered for long positions (EMA break, time exit, or emergency)
  • Short Exit - Fires when exit logic triggered for short positions
  • Squeeze Release - Fires when compression ends and expansion begins (potential breakout)
  • Predator Mode - Fires when strong trend alignment with favorable conditions (bull signal + low heat + ADX > 25 + no squeeze)


All alerts fire once per bar at bar close.

Bearish Alert Signal:
快照


## Technical Implementation Notes

  • Pine Script v6 compliant
  • All request.security calls use barmerge.gaps_off and barmerge.lookahead_off to prevent historical repainting
  • RSI divergence and liquidity sweep detection rely on confirmed pivot points only
  • All calculations include nz() wrappers and division-by-zero guards for real-time stability
  • Label cooldown system prevents visual overlap using priority-based filtering
  • Dashboard updates only on last confirmed history bar or realtime to optimize performance
  • Plot count optimized to stay within TradingView's 64-plot limit



## Usage Considerations

Timeframe Selection: The indicator works across all timeframes. Default confirmation timeframes (4H/1H) are optimized for swing and intraday trading. Scalpers may prefer 15m/5m confirmation; position traders may extend to Daily/4H.

Market Compatibility: Tested on forex, crypto, stocks, and indices. Pattern detection works best on liquid markets with clean price action. Adjust volume lookback for markets with irregular volume data.

Signal Interpretation: Signals indicate confluence across multiple dimensions but do not guarantee profitable outcomes. Use in conjunction with risk management and market context. The indicator is a tool for analysis, not a standalone trading system.

Resource Usage: With all features enabled, the script operates within TradingView's resource budgets. Disable unused visual elements (camouflage bands, pattern heat histogram, risk pulse panel) if running multiple instances on a single layout.


## Limitations & Compromises

  • Heat, drawdown, and performance values are chart-derived proxies dependent on your inputs-they do not reflect actual portfolio performance
  • The indicator does not know your broker fills, fees, leverage, slippage, or actual portfolio holdings
  • VaR, Sharpe, Sortino, and Hit Rate are simplified proxies using chart data, not audited statistics
  • Pattern detection may produce false signals during extended consolidation or low-volume conditions
  • Multi-timeframe confirmation requires sufficient historical data on higher timeframes
  • Signals are informational-always use broker-side risk controls and proper position sizing
  • Past pattern performance does not guarantee future results


The indicator is optimized for trending and reversal markets. Performance may degrade during extended sideways consolidation or during major news events when patterns become unreliable.


## Disclaimer

This script is provided for informational and educational purposes only and does not constitute financial advice. Trading involves substantial risk of loss. You are solely responsible for your own trading decisions. Past results shown on any chart do not guarantee future performance. Always conduct your own analysis and use appropriate risk management.

If anyone has any questions please feel free to talk to me on anything! Would love to help everyone out!

Made with passion by officialjackofalltrades


免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。