OPEN-SOURCE SCRIPT
Smart MACD Crossover

█ OVERVIEW
Smart MACD Crossover is an indicator designed for traders who trade based on MACD line crossovers. It significantly reduces the number of false crossover signals by adding a breakout-box confirmation mechanism. Price must close outside the box created at the moment of the MACD crossover for a signal to trigger. The script also includes optional scaled MACD lines on the price chart, candle coloring, multi-layer “fog” visualization, fully customizable entry signals, automatic Take Profit / Stop Loss levels and a real-time table.
█ CONCEPTS
Standard MACD crossovers frequently produce noise, especially in ranging markets. Smart MACD Crossover attempts to solve this issue: a horizontal box is drawn at the exact bar where the crossover occurs, and a trade signal is generated only when price actually breaks out of that box. By default, the show_only_matching filter is enabled — signals are shown only when the breakout direction matches the original MACD crossover direction (bullish box → long only, bearish box → short only).
█ FEATURES
Fully configurable classic MACD (default 12/26/9)
Optional MACD & Signal lines scaled and plotted directly on the price chart (show_macd_overlay)
Trend-based candle coloring
One-Side Histogram Fog:
- 6 layers above and 6 layers below hl2
- layer height based on average candle size × offset_mult (default 0.7)
- increasing transparency (base 80 + increment 4) for depth effect
- fully customizable colors
Breakout Boxes:
- created on every MACD crossover
- default height = high-low of the signal candle
- optional extension using average candle size × box_multiplier
- semi-transparent fill (85) with colored borders, extended right until breakout
Signals:
- Triangles or “BUY” / “SELL” labels
- show_only_matching filter (enabled by default) — only direction-consistent breakouts generate signals
- when disabled, every box breakout generates a signal according to breakout direction
- Built-in alerts: BUY and SELL
Take Profit / Stop Loss:
- TP1, TP2, TP3 and SL levels drawn automatically after each confirmed signal
- two modes: Candle Multiplier (based on average candle size) or Percentage
- all multipliers/percentages fully adjustable in “Risk Management Settings”
- real-time table in the top-right corner showing current TP/SL prices
█ HOW TO USE
Add via Pine Editor → paste code → Add to Chart.
Settings overview:
- MACD Settings: lengths and source
- Risk Management Settings: TP/SL mode, multipliers/percentages, average candle period
- MACD Overlay Lines: toggle scaled MACD lines on price chart
- Fog: enable/disable, adjust height and transparency
- Visual Settings: candle coloring
- Boxes: optional size multiplier (use_box_multiplier)
- Signals: choose Triangles or Labels, enable/disable direction filter
Signal meaning:
- Triangle below bar / “BUY” label → upward breakout from a box created after bullish MACD crossover
- Triangle above bar / “SELL” label → downward breakout from a box created after bearish MACD crossover
- Open boxes = pending breakout zones
- Fog below price = bullish pressure, fog above price = bearish pressure
█ APPLICATIONS
The indicator reduces false signals coming from plain MACD crossovers. For additional trend confirmation, the scaled MACD lines can be enabled.
Entry into a position is triggered by the BUY/SELL signal generated after the breakout. The TP1–TP3 and SL levels are drawn automatically only for convenience and as a quick reference – they are fully optional and traders can (and usually should) use their own preferred exit strategies, trailing stops, partial closes, or other money-management methods.
█ NOTES
- Due to MACD line scaling onto the price chart, classic MACD divergences cannot be identified
Smart MACD Crossover is an indicator designed for traders who trade based on MACD line crossovers. It significantly reduces the number of false crossover signals by adding a breakout-box confirmation mechanism. Price must close outside the box created at the moment of the MACD crossover for a signal to trigger. The script also includes optional scaled MACD lines on the price chart, candle coloring, multi-layer “fog” visualization, fully customizable entry signals, automatic Take Profit / Stop Loss levels and a real-time table.
█ CONCEPTS
Standard MACD crossovers frequently produce noise, especially in ranging markets. Smart MACD Crossover attempts to solve this issue: a horizontal box is drawn at the exact bar where the crossover occurs, and a trade signal is generated only when price actually breaks out of that box. By default, the show_only_matching filter is enabled — signals are shown only when the breakout direction matches the original MACD crossover direction (bullish box → long only, bearish box → short only).
█ FEATURES
Fully configurable classic MACD (default 12/26/9)
Optional MACD & Signal lines scaled and plotted directly on the price chart (show_macd_overlay)
Trend-based candle coloring
One-Side Histogram Fog:
- 6 layers above and 6 layers below hl2
- layer height based on average candle size × offset_mult (default 0.7)
- increasing transparency (base 80 + increment 4) for depth effect
- fully customizable colors
Breakout Boxes:
- created on every MACD crossover
- default height = high-low of the signal candle
- optional extension using average candle size × box_multiplier
- semi-transparent fill (85) with colored borders, extended right until breakout
Signals:
- Triangles or “BUY” / “SELL” labels
- show_only_matching filter (enabled by default) — only direction-consistent breakouts generate signals
- when disabled, every box breakout generates a signal according to breakout direction
- Built-in alerts: BUY and SELL
Take Profit / Stop Loss:
- TP1, TP2, TP3 and SL levels drawn automatically after each confirmed signal
- two modes: Candle Multiplier (based on average candle size) or Percentage
- all multipliers/percentages fully adjustable in “Risk Management Settings”
- real-time table in the top-right corner showing current TP/SL prices
█ HOW TO USE
Add via Pine Editor → paste code → Add to Chart.
Settings overview:
- MACD Settings: lengths and source
- Risk Management Settings: TP/SL mode, multipliers/percentages, average candle period
- MACD Overlay Lines: toggle scaled MACD lines on price chart
- Fog: enable/disable, adjust height and transparency
- Visual Settings: candle coloring
- Boxes: optional size multiplier (use_box_multiplier)
- Signals: choose Triangles or Labels, enable/disable direction filter
Signal meaning:
- Triangle below bar / “BUY” label → upward breakout from a box created after bullish MACD crossover
- Triangle above bar / “SELL” label → downward breakout from a box created after bearish MACD crossover
- Open boxes = pending breakout zones
- Fog below price = bullish pressure, fog above price = bearish pressure
█ APPLICATIONS
The indicator reduces false signals coming from plain MACD crossovers. For additional trend confirmation, the scaled MACD lines can be enabled.
Entry into a position is triggered by the BUY/SELL signal generated after the breakout. The TP1–TP3 and SL levels are drawn automatically only for convenience and as a quick reference – they are fully optional and traders can (and usually should) use their own preferred exit strategies, trailing stops, partial closes, or other money-management methods.
█ NOTES
- Due to MACD line scaling onto the price chart, classic MACD divergences cannot be identified
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.