Refracted EMA for trend

ALifeToMake Updated   
This script is an evolution of "Refracted EMA" by fract, that you can find here:
The differences are in the design and intended uses of its early and pretty reliable signals.

This is a trend indicator, with signals and alerts, usable on any timeframe.

Note: 3 color themes are included: Light, dark, and my personal dark one. Feel free to change them in the code, and to remove the ones you don't need.

When it gives a signal (arrow), a horizontal line starts, and expands until there's a signal in the opposite direction.
As long as the price moves away from this line, then the move should logically be profitable
If the price ranges, or turns back in direction of the line, then it might be time to reconsider.

The background colors offer a complement of information:
- When the price moves away from the line, the bgcolor is normal.
- When there has been 2 candles in the opposite direction, then the bgcolor turns a little darker. It might be an early sign of range or reversal.
- When the current price breaks through the signal's closing price, the bgcolor turns gray or black (depending on the theme and colors you chose), signaling a significative divergence with the signal, and a possible reversal. It is common though, for the first candle after the signal to go in the opposite direction. It might be a good idea to wait at least 2 candles after the signal.

You can switch the alerts on, by right clicking the chart and clicking "add alert". Alerts happen only after the close of the candle. They display the timeframe they were added on.

- If up and down arrows alternate quickly, then the market is undecided, and it might not be a good idea to trade. Or maybe on other timeframes.
- Trading against the indicator's direction is probably not a good idea, unless there is a very VERY good reason for this (like buying the dip of an up trend, for ex).
- Looking at different timeframes quickly reveals the bigger picture of the price movements. For ex, if the 4h, 1h, 30 min are bullish, but the 5 min bearish, then there might be a long opportunity. But if the 5 min is bearish, and the 10 min turns bearish, and the 30 min turns bearish too, then there might be a reversal on its way.
- The line can be used as a reference to decide where to place your stop loss. It is rare that the price crosses this line, but it can absolutely happen. So use this idea with caution, manage and protect your positions wisely.
- You can, and probably should, use the alerts on different timeframes at the same time, to constantly update your understanding of the trend.

Always confirm your ideas by other means, like price action and indicators of a different nature.
Release Notes:
Better placement of the bgcolor under the candles.
Correction of a typo in the title.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?