PROTECTED SOURCE SCRIPT
BanShen MACD Ultimate Multi Signal System[SpeculationLab]

🧠 How This Script Works (Detailed Logic Breakdown)
This script is a closed-source, fully self-developed modular trading system centered around MACD divergence detection. It also includes auxiliary modules such as:
Vegas Tunnel trend filtering
Dynamic ATR-based stop placement
Engulfing candlestick pattern detection
RSI/OBV divergence modules
Fair Value Gap (FVG) recognition
A smart signal panel that consolidates all signals in real time
These components work together through a signal resonance framework, helping traders identify high-confluence, high-probability entry opportunities.
🔍 Why MACD Divergence Is the Core (Real-World Strategy Basis)
This system is based on a real-world trading strategy I’ve personally used and refined over time.
Through discretionary trading and backtesting, I discovered that divergence between price action and the MACD histogram — especially when certain structural conditions are met — produces a very high win rate.
Key observations include:
MACD peaks/troughs that are clean and well-shaped (defined pivot structure)
Large vertical differences between two MACD histogram extremes
Price making a higher high or lower low, while MACD does the opposite
Two or more divergences appearing consecutively, which creates a powerful reversal signal
These setups have proven extremely reliable in my experience. This script automates the detection of these conditions using strict logic filters.
🔷 1. MACD Divergence Engine (Core Module)
At its core, this script implements a multi-layered MACD divergence detection system, capable of identifying both **regular** and **consecutive** bullish/bearish divergences.
Key components of the logic:
- **Pivot-Based Peak Detection:**
Peaks and troughs in the MACD histogram are located using left/right lookback lengths.
These define valid turning points by requiring the center bar to be the highest (or lowest) compared to its neighbors.
- **Peak Size Thresholding:**
The height of the histogram peaks is compared to the standard deviation of MACD values.
Only peaks above a configurable multiplier (e.g., 0.1× stdev) are considered significant, filtering out noise.
- **Peak Ratio Filtering:**
For divergence to be valid, the size ratio between two histogram peaks must exceed a minimum threshold.
This prevents "flat" divergences with no meaningful MACD movement from triggering false signals.
- **Noise Suppression:**
A customizable threshold filters out weak histogram fluctuations between divergence points.
- **Price Action Confirmation:**
The divergence is only confirmed when the price forms a new high or low (depending on the type), and the MACD forms an opposing structure.
- **Consecutive Divergence Detection:**
For high-conviction setups, the script detects sequences of two or more divergences in the same direction.
These use stricter filters and flag rare but powerful market turning points.
Signals are plotted using plotshape() with visual differentiation between regular and consecutive setups. You can enable/disable each type individually.
⏰ Note: Histogram colors are styled similarly to TradingView’s built-in MACD for visual familiarity. However, this script is built entirely from scratch and does not reuse any internal TV code.
---
🔷 2. Trend Filtering via Vegas Tunnel
The **Vegas Tunnel** module plots 5 configurable EMAs (default: 12, 144, 169, 576, 676) to evaluate trend direction.
The trend is considered **bullish** when short EMAs (144/169) are positioned above long EMAs (576/676), and the price is interacting with the short EMA tunnel.
Conversely, a bearish condition is detected when the opposite is true.
A visual triangle marker highlights trend zones, and users can hide/show individual EMAs.
---
🔷 3. ATR-Based Dynamic Stop Loss
This module plots dynamic stop levels above and below the current price based on ATR.
Default setting uses 13-period ATR, and users can customize the multiplier or disable the plot.
It serves as a visual guide for risk management in live trades.
---
🔷 4. Engulfing Pattern Recognition
Candlestick-based signal detection:
- **Bullish Engulfing** occurs when a candle closes above the prior high, and the prior bar is bearish.
- **Bearish Engulfing** when a candle closes below the prior low, and the prior bar is bullish.
Users can modify the logic to use open/close levels for looser or stricter detection.
These patterns are highlighted using plotshape markers and optionally included in the signal table.
---
🔷 5. RSI and OBV Divergence Modules
These modules follow similar logic to the MACD engine:
- Use pivotlow() / pivothigh() to detect swing points.
- Confirm divergence only when price moves in one direction while RSI or OBV moves in the opposite direction.
- Require a minimum distance (in bars) between the two pivots.
- Require a certain ratio between two indicator values and their corresponding prices.
You can only enable **one of MACD/RSI/OBV divergences at a time** to avoid visual overlap, as they share the same subplot.
---
🔷 6. FVG (Fair Value Gap) Auto Detection
This module detects large single-direction price moves where price leaves a visible gap between candle 3 bars ago and 1 bar ago.
- **Bullish FVG**: high[3] < low[1]
- **Bearish FVG**: low[3] > high[1]
ATR-based filters are applied to eliminate minor gaps.
Each gap is drawn as a box and optionally extended, with a central line marking the midpoint (CE - Consequent Encroachment) level.
Traders often look for price to return to this level as an entry signal.
---
🔷 7. Smart Signal Table
All active signals (MACD, Vegas, RSI, OBV, Engulfing) are collected into a **real-time table** that displays current market bias.
- Each module reports whether it is currently giving a bullish (🟢) or bearish (🔴) condition.
- Helps users assess signal alignment (confluence).
- The table is updated every bar and appears in the bottom-right corner.
---
🔷 8. Watermark & Branding
The watermark displays the script name and author at the top-right, and can be toggled via settings.
📌 Not a Mashup — Structured System, Not a Stack of Indicators
⚠️ This is not a random mashup of unrelated indicators.
Every module in this system was intentionally designed to support the core MACD divergence logic by filtering, validating, or amplifying its signals.
Here's how the system achieves signal confluence and structure:
Vegas Tunnel acts as a macro trend filter, helping users determine whether to favor long or short trades.
For example, bullish MACD divergence is more reliable when confirmed by an uptrend in the Vegas EMAs. This prevents users from trading against momentum.
Engulfing Patterns serve as entry-level price action confirmation.
When a bullish engulfing candle appears near a MACD bullish divergence — and trend conditions from Vegas are aligned — the confluence increases dramatically.
This is especially powerful when multiple modules confirm in the same direction on the right side of the chart.
RSI and OBV Divergence modules offer redundant but independent momentum views.
Users may enable them selectively to validate MACD signals, or to use them as standalone alternatives when MACD is flat or noisy.
FVG Zones provide context for entries or targets.
For instance, a MACD bullish divergence forming near a bullish FVG gap increases the odds of reversal.
Price often "fills" these imbalances, which aligns well with reversal setups.
The Smart Signal Table aggregates signals from all modules and provides a visual, real-time overview of the current market bias.
This allows traders to act only when multiple signals are aligned — for example, when MACD is bullish, trend is up, and a bullish engulfing just printed.
Together, this framework creates a coherent decision-making system, where each tool has a defined role: trend filtering, signal confirmation, risk management, or entry detection.
🧩 It is modular in architecture, but not modular in purpose.
This system was not built by stacking indicators, but by integrating logic across modules to support a high-conviction MACD-based strategy.
🧬 Originality Statement
This script is entirely original, developed from scratch without using external libraries or public script code. The logic is fully custom, especially the consecutive divergence detection system and signal integration.
⚠️ Disclaimer
This script is for educational and informational purposes only and does not constitute financial advice. Trade at your own risk.
---
📘 中文简要说明:
这是一个完全原创、闭源的交易系统,核心逻辑为 MACD 柱状图背离信号的识别,配合多模块共振判断,构建出一个高胜率的多信号共振策略。
本指标模块化结构清晰,主要包括:
- MACD 背离识别(支持连续背离)
- Vegas EMA 隧道趋势过滤
- RSI / OBV 背离模块
- 吞没形态识别
- FVG 平衡区间自动标注
- ATR 动态止损提示
- 智能信号面板(整合所有信号并可视化)
所有模块均可单独开启/关闭,适配顺势、逆势或多周期的交易风格。
本脚本为个人实战策略的程序化实现,逻辑完全由零开发,未使用任何公用代码。适合希望提高交易胜率和信号精准度的用户使用。
免责声明:本指标仅用于技术分析学习与参考,不构成任何投资建议。请您独立判断,自行承担交易风险。
This script is a closed-source, fully self-developed modular trading system centered around MACD divergence detection. It also includes auxiliary modules such as:
Vegas Tunnel trend filtering
Dynamic ATR-based stop placement
Engulfing candlestick pattern detection
RSI/OBV divergence modules
Fair Value Gap (FVG) recognition
A smart signal panel that consolidates all signals in real time
These components work together through a signal resonance framework, helping traders identify high-confluence, high-probability entry opportunities.
🔍 Why MACD Divergence Is the Core (Real-World Strategy Basis)
This system is based on a real-world trading strategy I’ve personally used and refined over time.
Through discretionary trading and backtesting, I discovered that divergence between price action and the MACD histogram — especially when certain structural conditions are met — produces a very high win rate.
Key observations include:
MACD peaks/troughs that are clean and well-shaped (defined pivot structure)
Large vertical differences between two MACD histogram extremes
Price making a higher high or lower low, while MACD does the opposite
Two or more divergences appearing consecutively, which creates a powerful reversal signal
These setups have proven extremely reliable in my experience. This script automates the detection of these conditions using strict logic filters.
🔷 1. MACD Divergence Engine (Core Module)
At its core, this script implements a multi-layered MACD divergence detection system, capable of identifying both **regular** and **consecutive** bullish/bearish divergences.
Key components of the logic:
- **Pivot-Based Peak Detection:**
Peaks and troughs in the MACD histogram are located using left/right lookback lengths.
These define valid turning points by requiring the center bar to be the highest (or lowest) compared to its neighbors.
- **Peak Size Thresholding:**
The height of the histogram peaks is compared to the standard deviation of MACD values.
Only peaks above a configurable multiplier (e.g., 0.1× stdev) are considered significant, filtering out noise.
- **Peak Ratio Filtering:**
For divergence to be valid, the size ratio between two histogram peaks must exceed a minimum threshold.
This prevents "flat" divergences with no meaningful MACD movement from triggering false signals.
- **Noise Suppression:**
A customizable threshold filters out weak histogram fluctuations between divergence points.
- **Price Action Confirmation:**
The divergence is only confirmed when the price forms a new high or low (depending on the type), and the MACD forms an opposing structure.
- **Consecutive Divergence Detection:**
For high-conviction setups, the script detects sequences of two or more divergences in the same direction.
These use stricter filters and flag rare but powerful market turning points.
Signals are plotted using plotshape() with visual differentiation between regular and consecutive setups. You can enable/disable each type individually.
⏰ Note: Histogram colors are styled similarly to TradingView’s built-in MACD for visual familiarity. However, this script is built entirely from scratch and does not reuse any internal TV code.
---
🔷 2. Trend Filtering via Vegas Tunnel
The **Vegas Tunnel** module plots 5 configurable EMAs (default: 12, 144, 169, 576, 676) to evaluate trend direction.
The trend is considered **bullish** when short EMAs (144/169) are positioned above long EMAs (576/676), and the price is interacting with the short EMA tunnel.
Conversely, a bearish condition is detected when the opposite is true.
A visual triangle marker highlights trend zones, and users can hide/show individual EMAs.
---
🔷 3. ATR-Based Dynamic Stop Loss
This module plots dynamic stop levels above and below the current price based on ATR.
Default setting uses 13-period ATR, and users can customize the multiplier or disable the plot.
It serves as a visual guide for risk management in live trades.
---
🔷 4. Engulfing Pattern Recognition
Candlestick-based signal detection:
- **Bullish Engulfing** occurs when a candle closes above the prior high, and the prior bar is bearish.
- **Bearish Engulfing** when a candle closes below the prior low, and the prior bar is bullish.
Users can modify the logic to use open/close levels for looser or stricter detection.
These patterns are highlighted using plotshape markers and optionally included in the signal table.
---
🔷 5. RSI and OBV Divergence Modules
These modules follow similar logic to the MACD engine:
- Use pivotlow() / pivothigh() to detect swing points.
- Confirm divergence only when price moves in one direction while RSI or OBV moves in the opposite direction.
- Require a minimum distance (in bars) between the two pivots.
- Require a certain ratio between two indicator values and their corresponding prices.
You can only enable **one of MACD/RSI/OBV divergences at a time** to avoid visual overlap, as they share the same subplot.
---
🔷 6. FVG (Fair Value Gap) Auto Detection
This module detects large single-direction price moves where price leaves a visible gap between candle 3 bars ago and 1 bar ago.
- **Bullish FVG**: high[3] < low[1]
- **Bearish FVG**: low[3] > high[1]
ATR-based filters are applied to eliminate minor gaps.
Each gap is drawn as a box and optionally extended, with a central line marking the midpoint (CE - Consequent Encroachment) level.
Traders often look for price to return to this level as an entry signal.
---
🔷 7. Smart Signal Table
All active signals (MACD, Vegas, RSI, OBV, Engulfing) are collected into a **real-time table** that displays current market bias.
- Each module reports whether it is currently giving a bullish (🟢) or bearish (🔴) condition.
- Helps users assess signal alignment (confluence).
- The table is updated every bar and appears in the bottom-right corner.
---
🔷 8. Watermark & Branding
The watermark displays the script name and author at the top-right, and can be toggled via settings.
📌 Not a Mashup — Structured System, Not a Stack of Indicators
⚠️ This is not a random mashup of unrelated indicators.
Every module in this system was intentionally designed to support the core MACD divergence logic by filtering, validating, or amplifying its signals.
Here's how the system achieves signal confluence and structure:
Vegas Tunnel acts as a macro trend filter, helping users determine whether to favor long or short trades.
For example, bullish MACD divergence is more reliable when confirmed by an uptrend in the Vegas EMAs. This prevents users from trading against momentum.
Engulfing Patterns serve as entry-level price action confirmation.
When a bullish engulfing candle appears near a MACD bullish divergence — and trend conditions from Vegas are aligned — the confluence increases dramatically.
This is especially powerful when multiple modules confirm in the same direction on the right side of the chart.
RSI and OBV Divergence modules offer redundant but independent momentum views.
Users may enable them selectively to validate MACD signals, or to use them as standalone alternatives when MACD is flat or noisy.
FVG Zones provide context for entries or targets.
For instance, a MACD bullish divergence forming near a bullish FVG gap increases the odds of reversal.
Price often "fills" these imbalances, which aligns well with reversal setups.
The Smart Signal Table aggregates signals from all modules and provides a visual, real-time overview of the current market bias.
This allows traders to act only when multiple signals are aligned — for example, when MACD is bullish, trend is up, and a bullish engulfing just printed.
Together, this framework creates a coherent decision-making system, where each tool has a defined role: trend filtering, signal confirmation, risk management, or entry detection.
🧩 It is modular in architecture, but not modular in purpose.
This system was not built by stacking indicators, but by integrating logic across modules to support a high-conviction MACD-based strategy.
🧬 Originality Statement
This script is entirely original, developed from scratch without using external libraries or public script code. The logic is fully custom, especially the consecutive divergence detection system and signal integration.
⚠️ Disclaimer
This script is for educational and informational purposes only and does not constitute financial advice. Trade at your own risk.
---
📘 中文简要说明:
这是一个完全原创、闭源的交易系统,核心逻辑为 MACD 柱状图背离信号的识别,配合多模块共振判断,构建出一个高胜率的多信号共振策略。
本指标模块化结构清晰,主要包括:
- MACD 背离识别(支持连续背离)
- Vegas EMA 隧道趋势过滤
- RSI / OBV 背离模块
- 吞没形态识别
- FVG 平衡区间自动标注
- ATR 动态止损提示
- 智能信号面板(整合所有信号并可视化)
所有模块均可单独开启/关闭,适配顺势、逆势或多周期的交易风格。
本脚本为个人实战策略的程序化实现,逻辑完全由零开发,未使用任何公用代码。适合希望提高交易胜率和信号精准度的用户使用。
免责声明:本指标仅用于技术分析学习与参考,不构成任何投资建议。请您独立判断,自行承担交易风险。
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由且不受任何限制地使用它 — 在此處了解更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由且不受任何限制地使用它 — 在此處了解更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。