OPEN-SOURCE SCRIPT
Signal Generator: HTF EMA Momentum + MACD

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.
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.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.