OPEN-SOURCE SCRIPT

Breakout Range Signal with Quality Analysis [Dova Lazarus]

228
📌 Breakout Range Signal with Quality Analysis [Dova Lazarus]
🎓 Training-focused indicator for breakout logic, SL & TP behavior and signal quality assessment

🔷 PURPOSE
This tool identifies breakout candles from a calculated channel range and visually simulates entries, stop losses, and take profits, providing live and historical performance metrics.

⚙️ MAIN SETTINGS

1️⃣ Channel Setup

channel_length = 10 → how many candles are averaged to form channel boundaries

channel_multiplier = 0.0 → adds expansion above/below the base channel

channel_smoothing_type = SMA → smoothing method for high/low averaging

📊 The channel consists of two moving averages: one from highs, the other from lows. When expanded (via multiplier), it creates a buffer range for breakout validation.

2️⃣ Signal Detection

Body > Channel % = 50 → a breakout candle's body must exceed 150% of the channel width

Signal Mode:
 • Weak → every valid breakout candle is highlighted
 • Strong → only the first signal in a sequence is shown (helps reduce noise)

🟦 Bullish signals (blue):
 • Candle opens inside the channel
 • Closes above the channel
 • Body is large enough
 • Optional: confirms with trend (if enabled)

🟨 Bearish signals (yellow):
 • Candle opens inside the channel
 • Closes below the channel
 • Body is large enough
 • Optional: confirms with trend

3️⃣ Trend Filter (optional)

Enabled via checkbox

Uses a higher timeframe MA to filter signals

Bullish signals are allowed only if price is below the trend MA

Bearish signals only if price is above it

⏱️ trend_timeframe = 1D (typically set higher than the chart's timeframe)
🟢 Trend line is plotted if enabled

🎯 ENTRY, STOP LOSS & TAKE PROFIT LOGIC

SL and TP are based on channel width, not fixed pip/tick size:

📍 Entry Price = close of the breakout candle

🛑 Stop Loss:
 • Bullish → below the lower channel border (minus offset)
 • Bearish → above the upper channel border (plus offset)

🎯 Take Profit:
 • Bullish → entry + channel width × profit multiplier
 • Bearish → entry − channel width × profit multiplier

You can control:

Profit Target Multiplier (e.g., 1.0 → TP = 1×channel width)

Stop Loss Target Multiplier (e.g., 0.5 → SL = 0.5×channel width)

Signals to Show = how many historical SL/TP setups to display

📈 Lines and labels ("TP", "SL") are drawn on the chart for clarity.

🧪 QUALITY ANALYSIS MODULE

If enabled, the indicator will:

Track each new signal (entry, SL, TP)

Analyze outcomes:
 • Win = TP hit before SL
 • Loss = SL hit before TP
 • Expired = signal unresolved after N bars

Display statistics in a table (top-right corner):

📋 Table fields:

✅ Overall win rate

📈 Bullish win rate

📉 Bearish win rate

🔢 Total signals

🕓 Pending (still active trades)

Maximum bars to wait for outcome is customizable (max_bars_to_analyze).

📐 VISUALIZATION TOOLS

TP / SL lines per signal

Labels “TP” and “SL”

Optional channel lines and trendline for better context

Colored bars for valid signals (blue/yellow)

📌 BEST USE CASES

Understand how breakout signals are formed

Learn SL/TP logic based on dynamic range

Test how volatility affects trade outcomes

Use as a visual simulation of trade behavior over time

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.