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.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.