OPEN-SOURCE SCRIPT

Universal Breakout Strategy [KedArc Quant]

64
Description:

A flexible breakout framework where you can test different logics (Prev Day, Bollinger, Volume, ATR, EMA Trend, RSI Confirm, Candle Confirm, Time Filter) under one system.
Choose your breakout mode, and the strategy will handle entries, exits, and optional risk management (ATR stops, take-profits, daily loss guard, cooldowns).
An on-chart info table shows live mode values (like Prev High/Low, Bollinger levels, RSI, etc.) plus P&L stats for quick analysis.
Use it to compare which breakout style works best on your instrument and timeframe, whether intraday, swing, or positional trading


🔑 Why it’s useful

* Flexibility: Switch between breakout strategies without loading different indicators.
* Clarity: On-chart info table displays current mode, relevant indicator levels, and live strategy P&L stats.
* Testing efficiency: Quickly A/B test different breakout styles under the same backtest environment.
* Transparency: Every trade is rule-based and displayed with entry/exit markers.

🚀 How it helps traders

* Lets you experiment with breakout strategies quickly without loading multiple scripts.
* Helps identify which breakout method fits your instrument & timeframe.
* Gives clear on-chart visual + statistical feedback for confident decision-making.


⚙️ Input Configuration

* Breakout Mode → choose which strategy to test:

* *Prev Day* → breakouts of yesterday’s High/Low.
* *Bollinger* → Upper/Lower BB pierce.
* *Volume* → Breakout confirmed with volume above average.
* *ATR Stop* → Wide range breakout using ATR filter.
* *Time Filter* → Breakouts inside defined session hours.
* *EMA Trend* → Breakouts only in EMA fast > slow alignment.
* *RSI Confirm* → Breakouts with RSI confirmation (e.g. >55 for longs).
* *Candle Confirm* → Breakouts validated by bullish/bearish candle.
* Lookback / ATR / Bollinger inputs → adjust sensitivity.
* Intrabar mode → option to evaluate breakouts using bar highs/lows instead of closes.
* Table options → show/hide info table, show/hide P&L stats, choose corner placement.



📈 Entry & Exit Logic

* Entry → occurs when breakout condition of chosen mode is met.
* Exit → default exits via opposite signals or optional stop/target if enabled.
* Session filter → optional auto-flat at session end.
* P&L management → optional daily loss guard, cooldown between trades, and ATR-based stop/take profit.



❓ FAQ — Choosing the best setup

Q: Which strategy should I use for which chart?

* *Prev Day Breakouts*: Best on indices, FX, and liquid futures with strong daily levels.
* *Bollinger*: Works well in range-bound environments, or crypto pairs with volatility compression.
* *Volume*: Good on equities where breakout strength is tied to volume spikes.
* *ATR Stop*: Suits volatile instruments (commodities, crypto).
* *EMA Trend*: Useful in trending markets (stocks, indices).
* *RSI Confirm*: Adds momentum filter, better for swing trades.
* *Candle Confirm*: Ideal for scalpers needing visual confirmation.
* *Time Filter*: For intraday traders who want signals only in high-liquidity sessions.

Q: What timeframe should I use?

* Intraday traders → 5m to 15m (Time Filter, Candle Confirm).
* Swing traders → 1H to 4H (EMA Trend, RSI Confirm, ATR Stop).
* Position traders → Daily (Prev Day, Bollinger).

* Breakout
A trade entry condition triggered when price crosses above a resistance level (for longs) or below a support level (for shorts).

* Prev Day High/Low

Formula:
Prev High = High of (Day[1])
Prev Low = Low of (Day[1])

* Bollinger Bands

Formula:
Basis = SMA(Close, Length)
Upper Band = Basis + (Multiplier × StdDev(Close, Length))
Lower Band = Basis – (Multiplier × StdDev(Close, Length))

* Volume Confirmation
A breakout is only valid if:
Volume > SMA(Volume, Length)

* ATR (Average True Range)
Measures volatility.

Formula:
ATR = SMA(True Range, Length)
where True Range = max(High–Low, |High–Close[1]|, |Low–Close[1]|)

* EMA (Exponential Moving Average)

Weighted moving average giving more weight to recent prices.

Formula:
EMA = (Price × α) + (EMA[1] × (1–α))
with α = 2 / (Length + 1)

* RSI (Relative Strength Index)

Momentum oscillator scaled 0–100.

Formula:
RSI = 100 – (100 / (1 + RS))
where RS = Avg(Gain, Length) ÷ Avg(Loss, Length)

* Candle Confirmation

Bullish candle: Close > Open AND Close > Close[1]
Bearish candle: Close < Open AND Close < Close[1]
Win Rate (%)

Formula:
Win Rate = (Winning Trades ÷ Total Trades) × 100

* Average Trade P&L
Formula:
Avg Trade = Net Profit ÷ Total Trades

📊 Performance Notes

The Universal Breakout Strategy is designed as a framework rather than a single-asset optimized system. Results will vary depending on the chart, timeframe, and asset chosen.
On the current defaults (15-minute, INR-denominated example), the backtest produced 132 trades over the selected period. This provides a statistically sufficient sample size.
Win rate (~35%) is relatively low, but this is balanced by a positive reward-to-risk ratio (~1.8). In practice, a lower win rate with larger wins versus smaller losses is sustainable.
The average P&L per trade is close to breakeven under default settings. This is expected, as the strategy is not tuned for a single symbol but offered as a universal breakout framework.
Commissions (0.1%) and slippage (1 tick) are included in the simulation, ensuring realistic conditions.
Risk management is conservative, with order sizing set at 1 unit per trade. This avoids over-leveraging and keeps exposure well under the 5-10% equity risk guideline.

👉 Traders are encouraged to:
Experiment with inputs such as ATR period, breakout length, or Bollinger parameters.
Test across different timeframes and instruments (equities, futures, forex, crypto) to find optimal setups.
Combine with filters (trend direction, volatility regimes, or volume conditions) for further refinement.

⚠️ Disclaimer This script is provided for educational purposes only.
Past performance does not guarantee future results.
Trading involves risk, and users should exercise caution and use proper risk management when applying this strategy.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.