OPEN-SOURCE SCRIPT
Smart MA Crossover

█ OVERVIEW
"Smart MA Crossover" is a technical analysis indicator designed to enhance the effectiveness of strategies based on MA crossovers, combining classic moving average crossovers with breakouts from boxes and dynamic trend visualizations. The indicator is fully customizable—you can freely adjust both parameters and graphical elements.
█ CONCEPTS
Trading approaches based solely on moving average crossover moments generate a large number of false signals. Smart MA Crossover was created to improve this statistic. That's why boxes are added, which are formed from the candle where the MA crossover occurred and generate signals only upon breakout from them. The boxes have bullish (green) and bearish (red) colors. By default, the show_only_matching filter is enabled, displaying entry signals only when the breakout direction matches the box color (e.g., only upward for a bullish box). Boxes are by default the size of the candle on which the crossover occurred, but their size can be adjusted to suit your strategy via an optional average candle size multiplier.
█ FEATURES
- Moving Averages: Two configurable MAs (fast_length, default 10; slow_length, default 30) with selectable type (SMA, EMA, WMA, HMA, VWMA). Optionally displayed with gradient fill between them (color depends on trend: green for uptrend, red for downtrend).
- MA Gradient and Candle Coloring: Enable gradient fill between MAs (transparency: gradient_opacity, default 85) and dynamic candle coloring based on trend (green/red).
- Fog Gradient Trend: Multi-layered gradient "fog" around hl2, consisting of 5 levels up and down, with offset based on average candle size (offset_mult, default 0.7) and increasing transparency (base_transp, default 80; transp_inc, default 4). Fog colors are dynamic (green/red).
- Breakout Boxes: Created at the moment of MA crossover, extending to the right. Box height optionally multiplied by average candle size (use_box_multiplier, box_multiplier, default 1.0). Boxes close and generate a signal when price breaks out beyond the top/bottom edge.
Signals:
- Triangles: Green downward triangles (buy breakout) below the bar, red upward triangles (sell breakout) above the bar—only on breakouts matching direction (if show_only_matching = true). When the matching filter is disabled, every box generates a signal based not on the MA crossover, but on the breakout direction.
- Labels: “BUY” (green, below bar) and “SELL” (red, iabove bar) with transparent background (transparency 40).
- Matching Filter: The show_only_matching option limits signals to breakouts consistent with box direction (bullish box → only buy, bearish → only sell).
- Visualization: Gradient MA lines, fill between MAs, multi-layered fog with increasing transparency, boxes with transparent background (85) and colored borders, dynamic trend colors.
- Alerts: Built-in alerts for BUY and SELL signals (with message including ticker and timeframe).
█ HOW TO USE
Add to Chart: Apply the indicator via Pine Editor or the Indicators menu on TradingView.
Configure Settings:
- MA Settings: Adjust fast (fast_length, default 10) and slow (slow_length, default 30) MA lengths and type (ma_type, default SMA).
- Visualization: Enable/disable MA lines (show_ma_lines), MA gradient (use_gradient_ma), fog trend (show_fog), candle coloring (color_candles).
- Boxes and Breakouts: Enable candle size multiplier (use_box_multiplier) and set value (box_multiplier, default 1.0). Enable signal filter (show_only_matching).
- Signals: Choose type (signal_type): Triangles or Labels (Buy/Sell).
- Fog Trend: Adjust offset (offset_mult), base transparency (base_transp), and increment (transp_inc). Select trend colors (col_up, col_dn).
Signal Interpretation:
- Buy Signals: Green triangles below the bar or “BUY” label—on upward breakout from a bullish box (after bull cross).
- Sell Signals: Red triangles above the bar or “SELL” label—on downward breakout from a bearish box (after bear cross).
- Fog and Gradient: green fog/fill = uptrend; red = downtrend.
- Boxes: Active boxes indicate potential breakout zones; their closure confirms the move.
Signal Confirmation: Use with other tools, such as support/resistance levels, volume, or additional MAs to filter false crossovers.
█ APPLICATIONS
- MA Cross Strategies: Replace classic crossovers—boxes and breakouts eliminate many false signals, thereby increasing effectiveness. Confirm with other indicators, e.g., RSI, Fibonacci, FVG, pivot levels.
- Trend Following: Can be used as a classic trend indicator, especially with larger MA values.
█ NOTES
- Test the indicator across different timeframes and assets, adjusting MA lengths and box multiplier to market volatility.
- In consolidating markets, the indicator generates more false signals.
"Smart MA Crossover" is a technical analysis indicator designed to enhance the effectiveness of strategies based on MA crossovers, combining classic moving average crossovers with breakouts from boxes and dynamic trend visualizations. The indicator is fully customizable—you can freely adjust both parameters and graphical elements.
█ CONCEPTS
Trading approaches based solely on moving average crossover moments generate a large number of false signals. Smart MA Crossover was created to improve this statistic. That's why boxes are added, which are formed from the candle where the MA crossover occurred and generate signals only upon breakout from them. The boxes have bullish (green) and bearish (red) colors. By default, the show_only_matching filter is enabled, displaying entry signals only when the breakout direction matches the box color (e.g., only upward for a bullish box). Boxes are by default the size of the candle on which the crossover occurred, but their size can be adjusted to suit your strategy via an optional average candle size multiplier.
█ FEATURES
- Moving Averages: Two configurable MAs (fast_length, default 10; slow_length, default 30) with selectable type (SMA, EMA, WMA, HMA, VWMA). Optionally displayed with gradient fill between them (color depends on trend: green for uptrend, red for downtrend).
- MA Gradient and Candle Coloring: Enable gradient fill between MAs (transparency: gradient_opacity, default 85) and dynamic candle coloring based on trend (green/red).
- Fog Gradient Trend: Multi-layered gradient "fog" around hl2, consisting of 5 levels up and down, with offset based on average candle size (offset_mult, default 0.7) and increasing transparency (base_transp, default 80; transp_inc, default 4). Fog colors are dynamic (green/red).
- Breakout Boxes: Created at the moment of MA crossover, extending to the right. Box height optionally multiplied by average candle size (use_box_multiplier, box_multiplier, default 1.0). Boxes close and generate a signal when price breaks out beyond the top/bottom edge.
Signals:
- Triangles: Green downward triangles (buy breakout) below the bar, red upward triangles (sell breakout) above the bar—only on breakouts matching direction (if show_only_matching = true). When the matching filter is disabled, every box generates a signal based not on the MA crossover, but on the breakout direction.
- Labels: “BUY” (green, below bar) and “SELL” (red, iabove bar) with transparent background (transparency 40).
- Matching Filter: The show_only_matching option limits signals to breakouts consistent with box direction (bullish box → only buy, bearish → only sell).
- Visualization: Gradient MA lines, fill between MAs, multi-layered fog with increasing transparency, boxes with transparent background (85) and colored borders, dynamic trend colors.
- Alerts: Built-in alerts for BUY and SELL signals (with message including ticker and timeframe).
█ HOW TO USE
Add to Chart: Apply the indicator via Pine Editor or the Indicators menu on TradingView.
Configure Settings:
- MA Settings: Adjust fast (fast_length, default 10) and slow (slow_length, default 30) MA lengths and type (ma_type, default SMA).
- Visualization: Enable/disable MA lines (show_ma_lines), MA gradient (use_gradient_ma), fog trend (show_fog), candle coloring (color_candles).
- Boxes and Breakouts: Enable candle size multiplier (use_box_multiplier) and set value (box_multiplier, default 1.0). Enable signal filter (show_only_matching).
- Signals: Choose type (signal_type): Triangles or Labels (Buy/Sell).
- Fog Trend: Adjust offset (offset_mult), base transparency (base_transp), and increment (transp_inc). Select trend colors (col_up, col_dn).
Signal Interpretation:
- Buy Signals: Green triangles below the bar or “BUY” label—on upward breakout from a bullish box (after bull cross).
- Sell Signals: Red triangles above the bar or “SELL” label—on downward breakout from a bearish box (after bear cross).
- Fog and Gradient: green fog/fill = uptrend; red = downtrend.
- Boxes: Active boxes indicate potential breakout zones; their closure confirms the move.
Signal Confirmation: Use with other tools, such as support/resistance levels, volume, or additional MAs to filter false crossovers.
█ APPLICATIONS
- MA Cross Strategies: Replace classic crossovers—boxes and breakouts eliminate many false signals, thereby increasing effectiveness. Confirm with other indicators, e.g., RSI, Fibonacci, FVG, pivot levels.
- Trend Following: Can be used as a classic trend indicator, especially with larger MA values.
█ NOTES
- Test the indicator across different timeframes and assets, adjusting MA lengths and box multiplier to market volatility.
- In consolidating markets, the indicator generates more false signals.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.