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提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。