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.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.