OPEN-SOURCE SCRIPT

Candle Sweep Long/Short with LVN

692
Overview
The Candle Sweep Long/Short with LVN is a sophisticated Pine Script indicator for TradingView that identifies high-probability sweep trading opportunities by detecting when price sweeps recent swing highs or lows while incorporating multiple validation filters. This multi-layered approach combines candle pattern analysis, volume confirmation, Low Volume Node (LVN) detection, RSI filtering, and consecutive candle analysis to generate reliable long and short signals.

Core Concept
The indicator works on the principle that when price sweeps a recent extreme (breaking above a swing high or below a swing low) but closes back within the range, it often indicates a false breakout. This creates potential reversal opportunities that the script captures. However, unlike simpler sweep strategies, this indicator adds robust filtering to significantly reduce false signals.

Key Features
1. Sweep Detection Logic
Long Signals: Identifies when price breaks below the lowest low of the lookback period but closes above that level (bullish sweep)

Short Signals: Detects when price breaks above the highest high of the lookback period but closes below that level (bearish sweep)

Configurable lookback period (1-50 bars) to adjust sweep sensitivity

2. Advanced Filtering System
Candle Quality Filters
Close Position Requirement: Candle must close in the top/bottom X% of its range (default 70%), confirming strong directional momentum

Range Filter: Optionally requires signal candle to be larger than the prior candle by a minimum percentage, filtering out low-volatility signals

Body Size Filter: Ensures the candle body represents a minimum percentage of the total range, confirming genuine directional conviction

Consecutive Candle Filter (NEW)
Invalidates long signals if X or more consecutive red candles appeared before the signal

Invalidates short signals if X or more consecutive green candles appeared before the signal

Helps avoid entering against established momentum trends

RSI Filter
Long signals can be invalidated if RSI is above overbought levels or below its moving average

Short signals can be invalidated if RSI is below oversold levels or above its moving average

All filter conditions can be independently enabled/disabled

3. Low Volume Node (LVN) Validation (NEW - Expanded to 16 Zones)
Manually define up to 16 LVN zones (areas of low trading volume acting as key support/resistance)

Signals are only valid if the candle touches an LVN zone AND closes beyond the 50% midpoint of that zone

LVN zones are visually displayed as semi-transparent gray boxes on the chart

Each LVN zone can be independently defined with high/low prices

4. Visual Signals & Alerts
Long signals: Green triangle below the candle with "LONG" label

Short signals: Red triangle above the candle with "SHORT" label

Signal candle highlighting: Candles with valid signals are colored green/red with reduced opacity

Black candle overlay (optional): Colors signal candles black if the next candle moves opposite to the signal direction, helping visualize failed signals

Alert conditions: Configurable alerts for sweep signal detection

Technical Parameters
Signal Parameters
Close in Top/Bottom X% of Range (0-100%): Determines how extreme the close must be relative to the candle range

Sweep Lookback Bars (1-50): Number of bars to look back for swing points

Range Filter
Require Signal Candle Larger Than Prior Candle: Toggle the range filter

Minimum % Larger Than Prior Candle: The minimum percentage by which the signal candle must exceed the prior candle's range

Body Size Filter
Minimum Body Size (% of Range): Minimum candle body percentage required (excludes doji-like candles)

Consecutive Opposite Candles Filter
Consecutive Red Candles Required to Invalidate Long (1-10)

Consecutive Green Candles Required to Invalidate Short (1-10)

RSI Filter Parameters
RSI Length (default 14)

Overbought/Oversold levels (default 70/30)

RSI Moving Average Length (default 9)

Individual toggle for each invalidation condition

LVN Settings
Up to 16 customizable LVN price zones

Toggle LVN filter on/off

Toggle LVN box visibility on/off

Trading Strategy Application
Ideal Use Cases
Range-bound markets: Excellent for identifying false breakouts in consolidation phases

Mean reversion strategies: Signals often occur when price temporarily moves outside the range before reverting

Reversal trading: Captures potential trend reversals when combined with RSI and LVN validation

Best Practices
Use higher timeframes (15min+) for more reliable signals

Consider using in conjunction with volume analysis for confirmation

Apply stricter LVN and RSI filters in volatile markets

Use the consecutive candle filter to avoid counter-trend entries

Customization Flexibility
The indicator offers extensive customization with toggles for each filter type, allowing traders to:

Disable any filter for simpler strategies

Adjust parameters to match specific market conditions

Add or remove LVN zones as market structure evolves

Fine-tune RSI conditions to match personal risk tolerance

Comparative Advantages
Comprehensive filtering: More filters than typical sweep indicators, reducing false signals

LVN integration: Unique ability to validate sweeps against known volume nodes

Visual clarity: Clear signal markers and optional LVN visualization

Flexibility: All components can be independently adjusted or disabled

Limitations & Considerations
Requires manual LVN zone definition (not automatically detected)

May generate fewer signals with all filters enabled (quality over quantity)

RSI and LVN filters may cause signals to appear after significant price movement

Best used in conjunction with other analysis tools for trade management

This indicator is suitable for traders looking for high-quality sweep signals with multiple confirmation layers, particularly those who trade breakouts, reversals, and mean reversion strategies in ranging markets.

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.