Ultimate RSI Indicator for ThinkorSwim

@Leo1015 The link to tradingview has manually drawn lines. That might be your best solution. The script you displayed does not draw any divergence lines.
 
@horserider , thanks for youor response. Any possibilty of integrating auto lines into your script for normal and hidden divergences? I would prefer without the Bollinger bands
 
Can someone please convert this script to TOS? Thank you

Code:
//@version=3
strategy("Bollinger + RSI, Double Strategy Long-Only (by ChartArt) v1.2", shorttitle="CA_-_RSI_Bol_Strat_1.2", overlay=true)

// ChartArt's RSI + Bollinger Bands, Double Strategy UPDATE: Long-Only
//
// Version 1.2
// Idea by ChartArt on October 4, 2017.
//
// This strategy uses the RSI indicator
// together with the Bollinger Bands
// to buy when the price is below the
// lower Bollinger Band (and to close the
// long trade when this value is above
// the upper Bollinger band).
//
// This simple strategy only longs when
// both the RSI and the Bollinger Bands
// indicators are at the same time in
// a oversold condition.
//
// In this new version 1.2 the strategy was
// simplified by going long-only, which made
// it more successful in backtesting.
//
// List of my work:
// https://www.tradingview.com/u/ChartArt/
//
//  __             __  ___       __  ___
// /  ` |__|  /\  |__)  |   /\  |__)  | 
// \__, |  | /~~\ |  \  |  /~~\ |  \  | 
//
//


///////////// RSI
RSIlength = input(6,title="RSI Period Length")
RSIoverSold = 50
RSIoverBought = 50
price = close
vrsi = rsi(price, RSIlength)


///////////// Bollinger Bands
BBlength = input(200, minval=1,title="Bollinger Period Length")
BBmult = 2 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(price, BBlength)
BBdev = BBmult * stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
buyEntry = crossover(source, BBlower)
sellEntry = crossunder(source, BBupper)
plot(BBbasis, color=aqua,title="Bollinger Bands SMA Basis Line")
p1 = plot(BBupper, color=silver,title="Bollinger Bands Upper Line")
p2 = plot(BBlower, color=silver,title="Bollinger Bands Lower Line")
fill(p1, p2)


///////////// Colors
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")
TrendColor = RSIoverBought and (price[1] > BBupper and price < BBupper) and BBbasis < BBbasis[1] ? red : RSIoverSold and (price[1] < BBlower and price > BBlower) and BBbasis > BBbasis[1] ? green : na
barcolor(switch1?TrendColor:na)
bgcolor(switch2?TrendColor:na,transp=50)


///////////// RSI + Bollinger Bands Strategy
long = (crossover(vrsi, RSIoverSold) and crossover(source, BBlower))
close_long = (crossunder(vrsi, RSIoverBought) and crossunder(source, BBupper))

if (not na(vrsi))

    if long
        strategy.entry("RSI_BB", strategy.long, stop=BBlower, oca_type=strategy.oca.cancel, comment="RSI_BB")
    else
        strategy.cancel(id="RSI_BB")
        
    if close_long
        strategy.close("RSI_BB")


//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
 
@CountVlad Post#1 contains the same data as the TradingView indicator. You can modify the presentation to your needs.
 
I'm not sure if it's possible to add some labels, (like the kind that are in the upper left) based on lower indicators, but I was wondering if it's possible. I was looking for something like a label to say "RSI>50" thats green and "RSI<50" Red, then maybe one another color that says rsi1>68 and rsi1<32. Then maybe another that says RSI1> RSI2 green, "RSI1<RSI2" red. then another one that saying RSI1>BBmidline green and RSI1<BBmidline red. maybe another saying BBmidline > or = 68 "reversal" red and BBmidline< or = 32 "reversal" green. I have some basic thinkscript abilities, so I may be able to finish it up if someone were able to point me in the right direction.
 
I'm not sure if it's possible to add some labels, (like the kind that are in the upper left) based on lower indicators, but I was wondering if it's possible. I was looking for something like a label to say "RSI>50" thats green and "RSI<50" Red, then maybe one another color that says rsi1>68 and rsi1<32. Then maybe another that says RSI1> RSI2 green, "RSI1<RSI2" red. then another one that saying RSI1>BBmidline green and RSI1<BBmidline red. maybe another saying BBmidline > or = 68 "reversal" red and BBmidline< or = 32 "reversal" green. I have some basic thinkscript abilities, so I may be able to finish it up if someone were able to point me in the right direction.
Add to the bottom of your script:
Ruby:
AddLabel(yes,
if rsi>68  then "rsi1>68" else
if rsi<32 then "rsi1<32" else
if RSI>50 then "RSI1>50"  else
if RSI<50 then "RSI1<50" else  " ",
if rsi>68  then  color.cyan  else
if rsi<32 then   color.magenta else
if RSI>50 then  color.green else
if RSI<50 then  color. Red else color.light_gray);

AddLabel(yes,
if RSI>RSI2 then "RSI1> RSI2" else "RSI1<RSI2",
if RSI>RSI2 then color.green else color.red );

AddLabel(yes,
if RSI>midline then "RSI1>BBmidline"  else "RSI1<BBmidline red",
if RSI>midline then  color.green else color.red) ;

AddLabel(midline>= 68 or midline<= 32,
if midline>= 68 then "OB reversal"  else
if midline<32 then  "OS reversal" else " ",
if midline>= 68 then color.red  else
if midline<32 then color.green else color.light_gray);
 
@horserider This thread has been dead for a while but I just wanted to ask if it was possible to have a painting strategy added to the code whenever the rsi changes colors. I basically want the candlesticks to change colors because it would be much easier to interpret the indicator. I tried doing it myself but I think its a little bit more complicated.

assignpriceColor(if MAIN > SIGNAL then color.GREEN else color.current);
assignpriceColor(if MAIN < SIGNAL then color.RED else color.current);

The error i'm getting is MAIN and SIGNAL.
 
it only highlights the first color, blue, but doesn't highlight the second color, orange. I think it might be doing that because the RSI2 never goes below RSI. I inputted the midline BB into the code and it started to highlight the colors properly. If anyone wants candlesticks to paint when the RSI is below or above the midline BB then just add this to the bottom of your code:

AssignPriceColor(
if RSI > midline then Color.green else
if RSI2 < midline then Color.red else Color.gray);
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
427 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