OPEN-SOURCE SCRIPT

Signal Generator: HTF EMA Momentum + MACD

49
Signal Generator: HTF EMA Momentum + MACD

What this script does
This indicator combines a higher-timeframe EMA trend filter with a MACD crossover on the chart’s timeframe. The goal is to make MACD signals more selective by checking whether they occur in the same direction as the broader trend.

How it works
- On the higher timeframe, two EMAs are calculated (short and long). Their difference is used as a simple momentum measure.

- On the chart timeframe, the MACD is calculated. Crossovers are then filtered with two conditions:
1.They must align with the higher-timeframe EMA trend.
2.They must occur beyond a small “zero band” threshold, with a minimum distance between MACD and signal lines.

- When both conditions are met, the script can plot BUY or SELL labels. ATR is used only to shift labels up or down for visibility.

Visuals and alerts
- Histogram bars show whether higher-timeframe EMA momentum is rising or falling.
- MACD main and signal lines are plotted with optional scaling.
- Dotted lines show the zero band region.
- Optional large BUY/SELL labels appear when conditions are confirmed on the previous bar.
- Alerts can be enabled for these signals; they trigger once per bar close.

Notes and limitations
- Higher-timeframe values are only confirmed once the higher-timeframe candle has closed.
- Scaling factors affect appearance only, not the logic.
- This is an open-source study intended as a learning and charting tool. It does not provide financial advice or guarantee performance.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.