OPEN-SOURCE SCRIPT
SLG's EMA+MACD Signal Trading Strategy M15

Trading Concept Overview
Disclaimer / Risk Notice
Trading financial markets involves significant risk and may not be suitable for all investors. Past performance is not indicative of future results.
Market conditions can change rapidly and unpredictably, and no strategy can guarantee profits. Always use proper risk management and position sizing.
This strategy is for educational and informational purposes only. Users are responsible for their own trading decisions.
- This strategy combines trend-following and momentum confirmation to identify high-probability entries in both long and short directions. It uses EMA-based trend filtering and MACD signal analysis, while managing risk dynamically using ATR-based stop loss and take profit.
- 1. Trend Identification
- The strategy calculates a Trend EMA (emaTrend) with a user-defined period (emaTrendLen) to determine the overall market direction:
- Bullish Trend: Price closes above the Trend EMA → only long trades are considered.
- Bearish Trend: Price closes below the Trend EMA → only short trades are considered.
- This ensures trades are aligned with the larger trend, avoiding counter-trend signals.
- 2. Momentum Signal with MACD
- MACD Calculation:
- fastEMA - slowEMA generates the MACD line.
- Signal line is an EMA of the MACD line.
- delta = MACD - Signal measures the momentum difference.
- Entry Logic:
- Long Signal: delta crosses above zero AND the price is above the Trend EMA.
- Short Signal: delta crosses below zero AND the price is below the Trend EMA.
- This ensures that entries occur only when momentum is aligned with the overall trend.
- 3. Dynamic Risk Management (ATR-based SL/TP)
- Uses Average True Range (ATR) to dynamically set stop loss and take profit:
- Long Trade:
- Stop Loss = Close - ATR * atrSLMult
- Take Profit = Close + ATR * atrTPMult
- Short Trade:
- Stop Loss = Close + ATR * atrSLMult
- Take Profit = Close - ATR * atrTPMult
- This allows the strategy to adapt to market volatility, protecting capital in choppy conditions and scaling profit targets in trending markets.
- 4. Visual and Alert Features
- Plots:
- Trend EMA for visual trend guidance.
- MACD delta to observe momentum.
- Long/Short signals as small triangles directly on the chart.
- Alerts:
- Generates notifications for long and short signals to trigger timely trades.
- 5. Core Trading Philosophy
- Trend-Following Bias: Only trade in the direction of the trend EMA.
- Momentum Confirmation: Enter trades when the MACD delta confirms the move.
- Volatility-Adjusted Risk: Use ATR to dynamically scale stops and targets.
Disclaimer / Risk Notice
Trading financial markets involves significant risk and may not be suitable for all investors. Past performance is not indicative of future results.
Market conditions can change rapidly and unpredictably, and no strategy can guarantee profits. Always use proper risk management and position sizing.
This strategy is for educational and informational purposes only. Users are responsible for their own trading decisions.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。