PROTECTED SOURCE SCRIPT
Malama's Range Breakout

Malama's Range Breakout is a dynamic Pine Script v6 indicator designed to automatically detect periods of price consolidation (tight ranges) on any timeframe or market, visually highlight them with expandable boxes, and generate actionable signals for breakouts and wick-based reversals.
Key Features
Adaptive Consolidation Detection: Uses a volatility-adjusted threshold (ATR multiplier) over a user-defined lookback period to identify genuinely tight ranges, avoiding false detections in trending or high-volatility conditions.
Preset Profiles: Quickly switch between optimized settings for different trading styles:
Tight Ranges (Scalping): Short lookback, low threshold for frequent small-range setups.
Normal Ranges (Intraday): Balanced for day trading.
Swing Trading: Longer lookback for larger consolidations.
Options Selling (Chop): Very low threshold to capture extended sideways/choppy phases.
Custom: Full manual control.
Visual Elements: Draws semi-transparent boxes around detected ranges (with optional dashed midline), dynamically extending them until a valid breakout occurs. Limits historical boxes for clean charts.
Breakout Signals: Triggers buy/sell labels and alerts only on confirmed breakouts, optionally requiring a volume spike (above SMA threshold) for higher-probability momentum moves.
Wick Reversal Signals: Detects rejection wicks touching range boundaries (without closing outside), signaling potential fakeouts or early reversals. Optional next-bar confirmation (e.g., bearish candle after upper wick) reduces false signals.
Built-in Alerts: Separate alert conditions for range detection, bullish/bearish breakouts, and confirmed/unconfirmed wick reversals.
How It Works
The script continuously monitors the price range over the selected lookback period. When the range contracts below the ATR-based threshold, it initiates a consolidation box starting from the tightest point. The box expands with new highs/lows while price remains inside.
A true breakout closes outside the box (with optional volume confirmation) → ends the range and plots a directional signal.
Wicks probing boundaries without closing outside → flags potential rejection/reversal zones inside the range.
This combination helps traders anticipate volatility expansion after compression, while distinguishing strong momentum breakouts from traps/false breaks.
Why It's Useful
Unlike fixed-time Opening Range Breakout (ORB) tools or simple consolidation detectors, this indicator adapts to current market volatility (via ATR) and works across all timeframes—ideal for scalping tight intraday ranges, capturing swing consolidations, or identifying chop for premium-selling strategies. The volume filter and wick reversal detection add confluence, helping avoid low-conviction trades in ranging markets.
Usage Tips
Best on liquid assets (stocks, futures, forex, crypto).
Combine breakouts with trend filters (e.g., higher-timeframe EMA) for directional bias.
Use wick signals cautiously in strong trends—they shine in ranges or at key levels.
Test presets on your preferred timeframe; "Normal" is a solid default for most intraday work.
No repainting: All logic based on confirmed closes.
Key Features
Adaptive Consolidation Detection: Uses a volatility-adjusted threshold (ATR multiplier) over a user-defined lookback period to identify genuinely tight ranges, avoiding false detections in trending or high-volatility conditions.
Preset Profiles: Quickly switch between optimized settings for different trading styles:
Tight Ranges (Scalping): Short lookback, low threshold for frequent small-range setups.
Normal Ranges (Intraday): Balanced for day trading.
Swing Trading: Longer lookback for larger consolidations.
Options Selling (Chop): Very low threshold to capture extended sideways/choppy phases.
Custom: Full manual control.
Visual Elements: Draws semi-transparent boxes around detected ranges (with optional dashed midline), dynamically extending them until a valid breakout occurs. Limits historical boxes for clean charts.
Breakout Signals: Triggers buy/sell labels and alerts only on confirmed breakouts, optionally requiring a volume spike (above SMA threshold) for higher-probability momentum moves.
Wick Reversal Signals: Detects rejection wicks touching range boundaries (without closing outside), signaling potential fakeouts or early reversals. Optional next-bar confirmation (e.g., bearish candle after upper wick) reduces false signals.
Built-in Alerts: Separate alert conditions for range detection, bullish/bearish breakouts, and confirmed/unconfirmed wick reversals.
How It Works
The script continuously monitors the price range over the selected lookback period. When the range contracts below the ATR-based threshold, it initiates a consolidation box starting from the tightest point. The box expands with new highs/lows while price remains inside.
A true breakout closes outside the box (with optional volume confirmation) → ends the range and plots a directional signal.
Wicks probing boundaries without closing outside → flags potential rejection/reversal zones inside the range.
This combination helps traders anticipate volatility expansion after compression, while distinguishing strong momentum breakouts from traps/false breaks.
Why It's Useful
Unlike fixed-time Opening Range Breakout (ORB) tools or simple consolidation detectors, this indicator adapts to current market volatility (via ATR) and works across all timeframes—ideal for scalping tight intraday ranges, capturing swing consolidations, or identifying chop for premium-selling strategies. The volume filter and wick reversal detection add confluence, helping avoid low-conviction trades in ranging markets.
Usage Tips
Best on liquid assets (stocks, futures, forex, crypto).
Combine breakouts with trend filters (e.g., higher-timeframe EMA) for directional bias.
Use wick signals cautiously in strong trends—they shine in ranges or at key levels.
Test presets on your preferred timeframe; "Normal" is a solid default for most intraday work.
No repainting: All logic based on confirmed closes.
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya secara bebas dan tanpa apa-apa had – ketahui lebih di sini.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya secara bebas dan tanpa apa-apa had – ketahui lebih di sini.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.