TradingView
maybethatguy
May 13, 2023 8:52 PM

Divergence Indicator 

E-mini S&P 500 FuturesCME

Description

Description:
The Divergence Indicator (DI) is a powerful technical analysis tool designed to identify potential bullish and bearish signals based on multiple indicators, including RSI, Stochastic Oscillator, MACD, and EMA. It helps traders spot divergences between price and these indicators, indicating potential trend reversals or continuations.

How it Works:
The Divergence Indicator compares various indicators and their relationships with price to identify bullish and bearish signals. It considers conditions such as rising or falling values of the Stochastic Oscillator (%K), RSI, and MACD lines, as well as the crossover and crossunder of the MACD Line and Signal Line. Additionally, it evaluates the relationship between fast and slow Exponential Moving Averages (EMA) to detect divergences. When a bullish or bearish condition is met, circles are plotted on the chart to highlight the signals.

Usage:
To effectively utilize the Divergence Indicator, follow these steps:
1. Apply the DI indicator to your chart by adding it from the available indicators.
2. Customize the color settings to suit your preferences. The bullish and bearish colors determine the colors of the plotted circles.
3. Observe the circles plotted on the chart:
- Bullish circles indicate potential bullish signals.
- Bearish circles indicate potential bearish signals.
4. Interpret the signals provided by the indicator:
- A bullish signal may occur when there is price divergence accompanied by rising values of the Stochastic Oscillator (%K), RSI, and MACD lines, or when the MACD Line crosses above the Signal Line. Additionally, a histogram value close to zero may strengthen the signal.
- A bearish signal may occur when there is price divergence accompanied by falling values of the Stochastic Oscillator (%K), RSI, and MACD lines, or when the MACD Line crosses below the Signal Line. A histogram value close to zero may also strengthen the signal.
5. Be cautious of false signals by considering additional factors such as the relationship between the fast and slow Exponential Moving Averages (EMA). If the EMAs or MACD values do not support the identified divergence, the signal may be less reliable.
6. Combine the signals from the Divergence Indicator with other technical analysis tools, such as support and resistance levels, trend lines, or candlestick patterns, to confirm potential trade setups.
7. Implement appropriate risk management strategies, including setting stop-loss orders and position sizing, to manage your trades effectively and protect your capital.

Note: The Divergence Indicator provides valuable insights into potential trend reversals or continuations based on divergences between price and multiple indicators. However, it is recommended to use this indicator in conjunction with other technical analysis tools and perform thorough analysis before making trading decisions.

Release Notes

Bullish and bearish color options have been moved to the top of the settings menu.

Release Notes

Alerts have been added to the script.

Release Notes

Alerts happen only when a candle closes with a signal. The alert will happen at the beginning of the following candle.

Release Notes

Indicator shapes and locations are now customizable.

Release Notes

In the Indicator Settings:
1. The "Create Alerts" option has been moved to the top of the "Inputs" tab
2. Color, Shape, and Location options are all moved to the "Style" tab
Comments
abey_apay
very good
SpriteMcBain
I find this indicator most useful coming into a key level or right after a key level is broke and price starts to reverse with a signal.
maybethatguy
@SpriteMcBain, Thank you, It is great for consolidation also. Just be careful of false signals while the market is trending
SpriteMcBain
@maybethatguy, NP, I'm usually in my trade by the time the signal is there but it gives me quite a bit of confidence to hold to targets when it appears. I especially love if I enter on a 2 minute, then the 2 min signal appears, then a few minutes later the 5 minute signal appears. Those trades always turn out the best.
BigGuavaTrading
Great idea. The shape coding unfortunately hard codes the circles on the chart. I think you can modify the code as below to make it so the shapes and colors can be modified by the user. Try this out on your end and if successful, recommend publishing an update!

plotshape(bullish, “Bullish divergence", shape.circle, location.bottom, color.green, size=size.tiny)
plotshape(bearish, "Bearish divergence", shape.circle, location.top, color.red, size=size.tiny)
maybethatguy
@BigGuavaTrading, Great suggestion! Your code was very close. location.abovebar and location.belowbar are the location values. :) It has been done
BigGuavaTrading
@maybethatguy, of course! Well done and appreciate the quick turn!
maybethatguy
@BigGuavaTrading, I'm just hanging out on here at the moment :) Thanks again!
SpriteMcBain
My man, i can't seem to find a way to set an alert on a green, red, or any signal. Is it possible?
maybethatguy
@SpriteMcBain, Not that I'm aware of at the moment. I am relatively new to coding and am not sure if I need to code it into the script or if its just not possible. I'll send a message to PineCoders today to see if its possible to code into it and let you know👍
More