OPEN-SOURCE SCRIPT
Swing Breakout Strategy ver 1

Overview
A multi-confirmation swing strategy that seeks trend breakouts and adds three optional confluence modules: candlestick patterns, RSI/MACD regular divergences, and simple chart patterns (double top/bottom). Built for clarity, fast testing, and togglable debug markers.
Core Logic
Trend filter: SMA(50) vs SMA(200) + price vs SMA(21).
Breakout engine: Close breaks prior N-bar high/low (lookback configurable).
Momentum: Stochastic cross (optional view), MACD cross/zone, RSI regime (>50 or <50).
Volume: Above SMA(volume) filter.
Optional Confluence Modules
Candlestick analysis (enable/disable):
Bull/Bear Engulfing, Hammer, Shooting Star, Inside Bar (bull/bear flavors).
Divergence (enable/disable):
Regular divergences on RSI and MACD histogram using confirmed pivots (HH/LH or LL/HL).
Chart patterns (enable/disable):
Double Bottom (two similar lows + neckline break).
Double Top (two similar highs + neckline break).
Tolerance and pivot width are configurable.
Entries & Exits
Entry Long: Any of (Base Breakout + Trend + Momentum + Volume) OR enabled confluences (candles / divergence / pattern).
Entry Short: Symmetric logic for downside.
Risk management: Optional ATR-based stop loss and take profit (configurable length & multipliers).
Note: If you prefer confluences to be filters (AND), change the final buySignal/sellSignal lines accordingly.
Inputs (key)
SMA lengths (21/50/200), RSI length, Stochastic lengths & smoothing, MACD (12/26/9).
Breakout lookback, Volume SMA.
ATR exits (on/off, ATR length, SL/TP multipliers).
Toggles for Candlesticks, Divergences, Patterns, plus per-module debug markers.
Plots & Markers
Plots SMA 21/50/200.
Buy/Sell arrows on chart.
Optional debug markers for each condition (global-scope safe).
Divergence/pattern markers offset to the actual pivot/neckline bars.
Good Practices
Test on multiple timeframes and instruments; tune lookbacks and ATR multipliers.
Consider using the modules as filters in trending markets to reduce whipsaws.
Always forward-test and combine with position sizing.
Disclaimer
For educational purposes only. This is not financial advice. Trading involves risk.
Version & Credits
Pine Script® v6 — Strategy.
Developed by: Mohammed Bedaiwi.
A multi-confirmation swing strategy that seeks trend breakouts and adds three optional confluence modules: candlestick patterns, RSI/MACD regular divergences, and simple chart patterns (double top/bottom). Built for clarity, fast testing, and togglable debug markers.
Core Logic
Trend filter: SMA(50) vs SMA(200) + price vs SMA(21).
Breakout engine: Close breaks prior N-bar high/low (lookback configurable).
Momentum: Stochastic cross (optional view), MACD cross/zone, RSI regime (>50 or <50).
Volume: Above SMA(volume) filter.
Optional Confluence Modules
Candlestick analysis (enable/disable):
Bull/Bear Engulfing, Hammer, Shooting Star, Inside Bar (bull/bear flavors).
Divergence (enable/disable):
Regular divergences on RSI and MACD histogram using confirmed pivots (HH/LH or LL/HL).
Chart patterns (enable/disable):
Double Bottom (two similar lows + neckline break).
Double Top (two similar highs + neckline break).
Tolerance and pivot width are configurable.
Entries & Exits
Entry Long: Any of (Base Breakout + Trend + Momentum + Volume) OR enabled confluences (candles / divergence / pattern).
Entry Short: Symmetric logic for downside.
Risk management: Optional ATR-based stop loss and take profit (configurable length & multipliers).
Note: If you prefer confluences to be filters (AND), change the final buySignal/sellSignal lines accordingly.
Inputs (key)
SMA lengths (21/50/200), RSI length, Stochastic lengths & smoothing, MACD (12/26/9).
Breakout lookback, Volume SMA.
ATR exits (on/off, ATR length, SL/TP multipliers).
Toggles for Candlesticks, Divergences, Patterns, plus per-module debug markers.
Plots & Markers
Plots SMA 21/50/200.
Buy/Sell arrows on chart.
Optional debug markers for each condition (global-scope safe).
Divergence/pattern markers offset to the actual pivot/neckline bars.
Good Practices
Test on multiple timeframes and instruments; tune lookbacks and ATR multipliers.
Consider using the modules as filters in trending markets to reduce whipsaws.
Always forward-test and combine with position sizing.
Disclaimer
For educational purposes only. This is not financial advice. Trading involves risk.
Version & Credits
Pine Script® v6 — Strategy.
Developed by: Mohammed Bedaiwi.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.