Breakout Conditions
3.4 Signal Generation Logic
The model generates a signal when price exits a defined EMA-centered breakout channel under confirmation conditions.
The breakout determines directional bias, while confirmation filters (volume, consolidation structure, and prior candle behavior) reduce false positives by requiring participation and structural alignment.
Signals are visualized on the chart as markers. Trade activation is managed separately by the model's internal state to ensure only one trade is active at a time.
The model generates signals indicating potential trade setups. Trade execution is performed manually by the user and is not automated by the indicator.
3.4.1 Signal Conditions
A signal occurs when price breaks outside the breakout channel and confirmation filters pass.
Long Signal
A long signal marker is generated when all conditions are satisfied on the same bar:
close > upperBand- Volume spike condition (required for non-Forex markets)
- Sideways compression condition (if enabled)
- Green candle condition (if enabled)
- No active trade
Short Signal
A short signal marker is generated when all conditions are satisfied on the same bar:
close < lowerBand- Volume spike condition (required for non-Forex markets)
- Sideways compression condition (if enabled)
- Green candle condition (if enabled)
- No active trade
These rules determine signal markers only.
Trade activation is controlled separately by the model's internal state variable (tradeActive), which prevents overlapping trades.
3.4.2 Band Definition
The breakout channel is defined using an exponential moving average (EMA) and the recent price range.
The bands are EMA-centered, range-derived thresholds, rather than dispersion-based bands such as Bollinger Bands.
Let:
- = lookback length
- = exponential moving average over length
- = highest high over
- = lowest low over
Then:
The band width equals half of the recent price range centered around the EMA. This produces a breakout channel, rather than a volatility envelope.
The same band definition is used for both long and short signals.
3.4.3 Confirmation Filters and Gating Logic
This section defines each confirmation condition referenced in the signal rules.
Volume Spike (Participation Confirmation)
Purpose Require above-average participation during breakout bars to reduce weak breakouts.
Definition
A volume spike occurs when current volume exceeds a 20-period simple moving average (SMA) multiplied by a configurable multiplier.
Let:
volAvg = SMA(volume, 20)volSpike = volume > volAvg × volMultiplier
Exception
For marketType = Forex, the volume spike requirement is bypassed because Forex volume is not consistently comparable across market feeds.
For non-Forex markets, the volSpike condition must be satisfied for both long and short signals.
Sideways Compression (Base Tightness Filter)
Purpose
Favor breakouts that emerge from short consolidations rather than already-extended moves.
Definition
The reference implementation measures the price range across the three prior completed bars and compares it to an ATR-scaled threshold.
rangeRecent = max(high[1..3]) − min(low[1..3])- Pass condition:
rangeRecent ≤ ATR × baseTightnessMult
If requireSidewaysBase = false, the filter is treated as automatically satisfied.
This filter evaluates only prior bars (1–3) and does not include the breakout bar itself.
The filter applies equally to both long and short signals.
Green Candle Filter (Recent Bullishness Check)
Purpose
Require minimal recent upward closes before a breakout.
This filter is direction-agnostic and applies to both long and short signals.
Definition
The script counts bullish candles across the previous N bars.
A bullish candle is defined as:
close ≥ open
The breakout is allowed only if the count meets the required threshold.
- Lookback bars:
i = 1..greenBarsRequired - Pass condition:
numGreen ≥ greenBarsRequired
Configuration
If requireGreenBars = false, this filter is treated as automatically satisfied.
This filter evaluates prior bars only, not the breakout bar.
Single Active Trade Constraint (tradeActive Gating)
Purpose
Prevent overlapping trades and ensure stop and target levels remain clearly associated with one active trade.
Definition
The script maintains an internal state variable tradeActive.
- When
tradeActive = true, the model continues tracking the current trade. - New trades are not activated until the current trade exits.
This constraint applies to both long and short trades.
Signal markers may still appear when a breakout occurs while a trade is active.
Trade activation (entry, stop, target initialization) only occurs when
tradeActive = false.
3.4.4 Reference Implementation (Pine Script)
The following snippet illustrates the breakout condition logic implemented in the TradingView reference script.
// --- Breakout Conditions ---
longBreakout_base = close > upperBand and greenCheck and sidewaysCheck
shortBreakout_base = close < lowerBand and greenCheck and sidewaysCheck
bool finalLongBreakout = marketType == "Forex"
? longBreakout_base
: (longBreakout_base and volSpike)
bool finalShortBreakout = marketType == "Forex"
? shortBreakout_base
: (shortBreakout_base and volSpike)