Archived: RSI Divergence Indicator

Status
Not open for further replies.
Thanks for posting Indicator. I put a 15 Exponential MA overlay on the indicator and I think it enhances it.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Would somebody please make it so that it shows all of the divergences? It only shows the recent one but doesn't show other divergences in the past. Thank you.
 
@KhanhNguyen it will only display the newest divergence. It doesn’t show all.
@BenTen: I notice that the script also shows a false divergence where price makes higher, and RSI also makes higher high as you can see in picture #4. Is there a way to modify the script so that it only plots the dotted divergence where the price and RSI indicator moves the opposite direction?
 
Oh, sorry, it's really ordinary: daily time frame, scanning all stocks. With no other conditions. I thought maybe there's something in the code preventing using this condition for less than "within 7 bars"? It seems strange that there would be hundreds of hits for "within 7 bars" and zero for "within 6 bars".
I have the same problem. Can you figure out how to get it within 3 bars??
 
I am looking for code snippets that plot divergence lines between price and the RSI. I mean if the price has higher highs while RSI has a lower high (or vice versa). Instead of visually verifying the divergence, I want to be able to plot it.

Here is the code that I want to use to add these lines. @tomsk helped me and I made few tweaks.
Code:
# Divergence Updown Points
# tomsk  (modfied further by [USER=2184]@venus360[/USER])
# 1.17.2020

# Plots the ratio of Up/Down points relative to the prior candle

input period = 14;
declare lower;

def upPoints   = fold i = 0 to period
                 with p
                 do p + GetValue(if close > close[1] then close - close[1] else 0, i);
def downPoints = fold j = 0 to period
                 with r
                 do r + GetValue(if close < close[1] then close - close[1] else 0, j);

def au = upPoints / period;
def ad = AbsValue(downPoints) / period;

def ratio = au / ad;

def step0 = 1 + ratio;
def step1 = 100 / step0;
plot final = 100 - step1;

# End UpDown Points Divergence

0uufIZ1.png


I manually added the lines, I want to explore if the divergence lines can be plotted using code.
 
Last edited by a moderator:
I am having trouble using the scan. Can someone please explain step by step how to set up the scan with this RSI divergence. I followed the instructions but must be doing something wrong and nothing comes up. Thanks in advance.
 
I would love to have this as well! Is there any way to add values (meaning price Numbers to the RSI low points and high points) please, pretty please.
 
Unfortunately, I could not get any help on my request. I went ahead and purchased a script at funwiththinkscript that has a RSI divergence which seems to work very well. If there is any coder who can help with my above request, I would add sugar on top of @StockJockey's pretty please :)
 
Curious about this study too, can you show some examples of how it looks and how do you think it works for your trading? @venus360
 
Regarding funwiththinkscript's RSI divergence - Hindsight 20/20. That indicator showed negative divergence for all the indexes and many of the Dow stocks. I bought it after that unfortunately. The script I have above seems pretty close in terms of RSI values even though it uses completely different logic and math. I am able to use this in day trading as well as with daily charts. For day trading, I use 1000 ticks or 1 hr charts to get the best results. @Playstation - I haven't looked at that script. I will over the weekend and try it out next week. Thank you.
 
Here is an upper divergence study that you might like. It will plot points on the bars or there is a paintbar option.
The first image shows how many signals will pop up will removal of futurebar filter.
The second image shows how divergence can work wonders sometimes and other times in a strong directional push it will throw false signals.
The third image just shows the points instead of paintbars.


Code:
#RSI_DIVERGENCE_POINTS
#DeusMecanicus

declare upper;
input Length = 14;
input Price = close;
input AverageType = AverageType.WILDERS;
input Lookback1 = 20;
input Lookback2 = 50;
input Lookback3 = 100;
input PaintBars = No;
input HidePoints = No;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);

def futurebar = rsi > rsi[-1];
def futurebar1 = RSI < RSI[-1];
plot RSI_Div_Down1 = if rsi != Highest(rsi, Lookback1) and close == Highest(close, Lookback1) and futurebar then midbodyval() else Double.NaN;
RSI_Div_Down1.SetPaintingStrategy(PaintingStrategy.POINTS);
RSI_Div_Down1.AssignValueColor(Color.PINK);
RSI_Div_Down1.SetLineWeight(3);
plot RSI_Div_Down2 = if rsi != Highest(rsi, Lookback2) and close == Highest(close, Lookback2) and futurebar then midbodyval() else Double.NaN;
RSI_Div_Down2.SetPaintingStrategy(PaintingStrategy.POINTS);
RSI_Div_Down2.AssignValueColor(Color.RED);
RSI_Div_Down2.SetLineWeight(3);
plot RSI_Div_Down3 = if rsi != Highest(rsi, Lookback3) and close == Highest(close, Lookback3) and futurebar then midbodyval() else Double.NaN;
RSI_Div_Down3.SetPaintingStrategy(PaintingStrategy.POINTS);
RSI_Div_Down3.AssignValueColor(Color.DARK_RED);
RSI_Div_Down3.SetLineWeight(3);
plot RSI_Div_Up1 = if rsi != Lowest(rsi, Lookback1) and close == Lowest(close, Lookback1) and futurebar1 then midbodyval() else Double.NaN;
RSI_Div_Up1.SetPaintingStrategy(PaintingStrategy.POINTS);
RSI_Div_Up1.AssignValueColor(Color.GREEN);
RSI_Div_Up1.SetLineWeight(3);
plot RSI_Div_Up2 = if rsi != Lowest(rsi, Lookback2) and close == Lowest(close, Lookback2) and futurebar1 then midbodyval() else Double.NaN;
RSI_Div_Up2.SetPaintingStrategy(PaintingStrategy.POINTS);
RSI_Div_Up2.AssignValueColor(Color.DARK_GREEN);
RSI_Div_Up2.SetLineWeight(3);
plot RSI_Div_Up3 = if rsi != Lowest(rsi, Lookback3) and close == Lowest(close, Lookback3) and futurebar1 then midbodyval() else Double.NaN;
RSI_Div_Up3.SetPaintingStrategy(PaintingStrategy.POINTS);
RSI_Div_Up3.AssignValueColor(Color.CYAN);
RSI_Div_Up3.SetLineWeight(3);

RSI_DIV_Up1.sethiding(HidePoints);
RSI_DIV_Up2.sethiding(HidePoints);
RSI_DIV_Up3.sethiding(HidePoints);
RSI_DIV_Down1.sethiding(HidePoints);
RSI_DIV_Down2.sethiding(HidePoints);
RSI_DIV_Down3.sethiding(HidePoints);

AssignPriceColor(if !paintBars then Color.CURRENT else
if rsi != Highest(rsi, Lookback1) and close == Highest(close, Lookback1) and futurebar then Color.PINK else
if rsi != Highest(rsi, Lookback2) and close == Highest(close, Lookback2) and futurebar then Color.RED else
if rsi != Highest(rsi, Lookback3) and close == Highest(close, Lookback3) and futurebar then Color.DARK_RED else
if rsi != Lowest(rsi, Lookback1) and close == Lowest(close, Lookback1) and futurebar1 then Color.GREEN else
if rsi != Lowest(rsi, Lookback2) and close == Lowest(close, Lookback2) and futurebar1 then Color.DARK_GREEN else
if rsi != Lowest(rsi, Lookback3) and close == Lowest(close, Lookback3) and futurebar1 then Color.CYAN else Color.BLACK );
 
Last edited:
Hi, just did this:

If you wish to make this a Dynamic WatchList, save this scan with a name such as
RSI_With_Div_WL then in your Gadgets box click the little gear icon, locate the name of the
scan you just saved and click it. As equities match the scan criteria they will populate
the list.


But the study doesn't appears, what can I do?
 
I am not a coder and try my best to add a alert on this script but didn't work, can anyone figure out what mistake I made as below:

Alert(condition = pivotLow, text = "Buy", "alert type" = Alert.BAR, sound = Sound.chimes);

Alert(condition = pivotHigh, text = "Sell", "alert type" = Alert.BAR, sound = Sound.chimes);
 
I like this RSI Divergence Indicator very much, and try to add a alert script to it by myself but failed, and anyone do me a favor?
 
Status
Not open for further replies.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
487 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top