OPEN-SOURCE SCRIPT
EMA Trend Signals

EMA Trend Signals
OVERVIEW
EMA Trend Signals is a clean, lightweight trend-following tool built around two exponential moving averages (EMAs). It colors the trend, highlights the space between the two averages, and marks the exact bars where the fast average crosses the slow one — giving an at-a-glance read on direction and momentum shifts without cluttering the chart.
HOW IT WORKS
The script calculates two EMAs from a source of your choice:
• Fast EMA (default 21) — reacts quickly to recent price.
• Slow EMA (default 55) — represents the broader trend.
The relationship between them defines the regime:
• Fast EMA above the slow EMA → momentum is aligned to the upside → bullish (green).
• Fast EMA below the slow EMA → momentum is aligned to the downside → bearish (red).
An EMA is a weighted average that gives more importance to recent bars, so it follows price faster than a simple moving average while still smoothing out noise. Using two lengths separates short-term momentum (fast) from the prevailing trend (slow); the point where they cross is a classic, widely used signal for a potential shift in control between buyers and sellers.
WHAT IT DRAWS
• Fast EMA line, colored by the active trend (green / red).
• Slow EMA line as a neutral reference.
• A soft fill between the two EMAs, tinted by direction — a wider gap means stronger separation.
• An optional light background tint showing the current regime.
• Triangle markers on the exact bar where a cross occurs (up / down).
HOW TO USE IT
• Trend bias: read green as a long bias and red as a short bias. Many traders only take positions in the direction of the color.
• Signals: the up-triangle (fast crosses above slow) and down-triangle (fast crosses below slow) mark momentum shifts. They perform best in trending conditions and will whipsaw in tight ranges — pair them with your own structure, key levels, or a higher-timeframe filter.
• Tuning: shorten the lengths for faster, more frequent signals; lengthen them for fewer, smoother ones. Change the Source input to apply the logic to hl2, hlc3, and so on.
ALERTS
Two ready-made alerts are included — "EMA Cross Up" and "EMA Cross Down" — so you can be notified the moment a cross happens on any symbol or timeframe.
SETTINGS
• Source — price series the EMAs are built from (default close).
• Fast EMA length — short-term average (default 21).
• Slow EMA length — trend average (default 55).
• Trend background — toggle the regime tint.
• Cross markers — toggle the triangle shapes.
NOTES & LIMITATIONS
Moving-average crosses are lagging by nature: they confirm a move after it has already begun rather than predicting it, and they can produce false signals in sideways markets. This tool is a visual aid for trend direction and momentum shifts — it is not a complete trading system and does not manage risk or position size. Always confirm with your own analysis.
Open-source — feel free to study, use, and build on it.
For research and educational purposes only. This is not financial advice.
OVERVIEW
EMA Trend Signals is a clean, lightweight trend-following tool built around two exponential moving averages (EMAs). It colors the trend, highlights the space between the two averages, and marks the exact bars where the fast average crosses the slow one — giving an at-a-glance read on direction and momentum shifts without cluttering the chart.
HOW IT WORKS
The script calculates two EMAs from a source of your choice:
• Fast EMA (default 21) — reacts quickly to recent price.
• Slow EMA (default 55) — represents the broader trend.
The relationship between them defines the regime:
• Fast EMA above the slow EMA → momentum is aligned to the upside → bullish (green).
• Fast EMA below the slow EMA → momentum is aligned to the downside → bearish (red).
An EMA is a weighted average that gives more importance to recent bars, so it follows price faster than a simple moving average while still smoothing out noise. Using two lengths separates short-term momentum (fast) from the prevailing trend (slow); the point where they cross is a classic, widely used signal for a potential shift in control between buyers and sellers.
WHAT IT DRAWS
• Fast EMA line, colored by the active trend (green / red).
• Slow EMA line as a neutral reference.
• A soft fill between the two EMAs, tinted by direction — a wider gap means stronger separation.
• An optional light background tint showing the current regime.
• Triangle markers on the exact bar where a cross occurs (up / down).
HOW TO USE IT
• Trend bias: read green as a long bias and red as a short bias. Many traders only take positions in the direction of the color.
• Signals: the up-triangle (fast crosses above slow) and down-triangle (fast crosses below slow) mark momentum shifts. They perform best in trending conditions and will whipsaw in tight ranges — pair them with your own structure, key levels, or a higher-timeframe filter.
• Tuning: shorten the lengths for faster, more frequent signals; lengthen them for fewer, smoother ones. Change the Source input to apply the logic to hl2, hlc3, and so on.
ALERTS
Two ready-made alerts are included — "EMA Cross Up" and "EMA Cross Down" — so you can be notified the moment a cross happens on any symbol or timeframe.
SETTINGS
• Source — price series the EMAs are built from (default close).
• Fast EMA length — short-term average (default 21).
• Slow EMA length — trend average (default 55).
• Trend background — toggle the regime tint.
• Cross markers — toggle the triangle shapes.
NOTES & LIMITATIONS
Moving-average crosses are lagging by nature: they confirm a move after it has already begun rather than predicting it, and they can produce false signals in sideways markets. This tool is a visual aid for trend direction and momentum shifts — it is not a complete trading system and does not manage risk or position size. Always confirm with your own analysis.
Open-source — feel free to study, use, and build on it.
For research and educational purposes only. This is not financial advice.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。