TKP RSI Bar Color For ThinkOrSwim

BobbyJackson

New member
Plus
Author states: Traditional use of RSI is to use it as an "Overbought" and "Oversold" indicator. A more uncommon/unknown use, especially among new traders, is to use is as a "Momentum" indicator. I personally like to look for stocks where RSI>50
Default settings are set to color all bars red when below 50, and white when above 50, but try for your self setting different colors above 70, and below 30 to better see overbought and oversold conditions.

DiFwGRO.png


Here is the original Tradingview code:
https://www.tradingview.com/script/wSjHjLHz-TKP-RSI-BAR-COLOR/


For the new ThinkOrSwim code, you must scroll down to the next post
 
Last edited by a moderator:

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

https://www.tradingview.com/script/wSjHjLHz-TKP-RSI-BAR-COLOR/

Code:
/// This script was influenced by Scilentors-"RSI Bar Colors / Scilentor". I improved upon the idea by adding the ability to change the full range of RSI (Between 0 through 100) to any color you want within 5 point increments.
/// Traditional use of RSI is to use it as an "Overbought" and "Oversold" indicator. A more uncommon/unknown use, especially among new traders, is to use is as a "Momentum" indicator. I personally like to look for stocks where RSI>50
/// Default settings are set to color all bars red when below 50, and white when above 50, but try for your self setting different colors above 70, and below 30 to better see overbought and oversold conditions.
///I got a lot of requests for this script and I hope it helps you in your trading journey :)

study(title="TKP RSI BAR COLOR", overlay=true, shorttitle="TKP-RSI BC")

// RSI Formula//////////////////////////////////////////
src = close, len = input(14, minval=1, title="Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

// RSI Parameters//////////////////////////////////////////

RSI100 = rsi < 100 and rsi > 95
RSI95 = rsi < 95 and rsi > 90
RSI90 = rsi < 90 and rsi > 85
RSI85 = rsi < 85 and rsi > 80
RSI80 = rsi < 80 and rsi > 75
RSI75 = rsi < 75 and rsi > 70
RSI70 = rsi < 70 and rsi > 65
RSI65 = rsi < 65 and rsi > 60
RSI60 = rsi < 60 and rsi > 55
RSI55 = rsi < 55 and rsi > 50
RSI50 = rsi < 50 and rsi > 45
RSI45 = rsi < 45 and rsi > 40
RSI40 = rsi < 40 and rsi > 35
RSI35 = rsi < 35 and rsi > 30
RSI30 = rsi < 30 and rsi > 25
RSI25 = rsi < 25 and rsi > 20
RSI20 = rsi < 20 and rsi > 15
RSI15 = rsi < 15 and rsi > 10
RSI10 = rsi < 10 and rsi > 5
RSI5 = rsi < 5 and rsi > 0


// ////////////Color rules /////////////////////////////////


barcolor(RSI5 ? red : na, title = "RSI 0<>5")
barcolor(RSI10 ? red : na, title = "RSI 5<>10")
barcolor(RSI15 ? red : na, title = "RSI 10<>15")
barcolor(RSI20 ? red : na, title = "RSI 15<>20")
barcolor(RSI25 ? red : na, title = "RSI 20<>25")
barcolor(RSI30 ? red : na, title = "RSI 25<>30")
barcolor(RSI35 ? red : na, title = "RSI 30<>35")
barcolor(RSI40 ? red : na, title = "RSI 35<>40")
barcolor(RSI45 ? red : na, title = "RSI 40<>45")
barcolor(RSI50 ? red : na, title = "RSI 45<>50")
barcolor(RSI55 ? white : na, title = "RSI 50<>55")
barcolor(RSI60 ? white : na, title = "RSI 55<>60")
barcolor(RSI65 ? white : na, title = "RSI 60<>65")
barcolor(RSI70 ? white : na, title = "RSI 65<>70")
barcolor(RSI75 ? white : na, title = "RSI 70<>75")
barcolor(RSI80 ? white : na, title = "RSI 75<>80")
barcolor(RSI85 ? white : na, title = "RSI 80<>85")
barcolor(RSI90 ? white : na, title = "RSI 85<>90")
barcolor(RSI95 ? white : na, title = "RSI 90<>95")
barcolor(RSI100 ? white : na, title = "RSI 95<>100")

just wanted to bump this. Thank you
check the below, added more features:

CSS:
# @RolandoSantos
#study(title="TKP RSI BAR COLOR", overlay=true, shorttitle="TKP-RSI BC")
# converted by Sam4Cok@Samer800    - 01/2025

input timeframe = AggregationPeriod.MIN;
input colorBars = yes;
input signalType = {Default "Reversal Signal", "Trend Signal", "Don't Show"};
input src = FundamentalType.CLOSE;
input len = 14;
input overbought = 75;
input oversold = 25;

def na = DOuble.NaN;
def cap = GetAGgregationPeriod();
def tf = Max(cap, timeframe);

##// ~~ Gradient Coloring {
Script gradient_color {
input src = close;
input minVal = 10;
input maxVal = 400;
input loR = 173;
input loG = 216;
input loB = 230;
input hiR = 41;
input hiG = 98;
input hiB = 255;
    def value = if isNaN(src) then 0 else src;
    def clamped_value = max(min(value, maxVal), minVal);
    def normalized_value = (clamped_value - minVal) / (maxVal - minVal);
    def re = floor(loR + (hiR - loR) * normalized_value);
    def gr = floor(loG + (hiG - loG) * normalized_value);
    def bl = floor(loB + (hiB - loB) * normalized_value);
    plot r = re;
    plot g = gr;
    plot b = bl;
}
def nRSI = rsi(Price = Fundamental(src, period = tf), length = len);
def colR = gradient_color(nRSI, oversold, overbought, 255, 0, 0, 0, 255, 0).r;
def colG = gradient_color(nRSI, oversold, overbought, 255, 0, 0, 0, 255, 0).g;
def colB = gradient_color(nRSI, oversold, overbought, 255, 0, 0, 0, 255, 0).b;

def crossUp;
def crossDn;

Switch (signalType) {
Case "Don't Show" :
    crossUp = na;
    crossDn = na;
Case "Trend Signal" :
    crossUp = nRSI Crosses Above overbought;
    crossDn = nRSI Crosses Below oversold;
Default :
   crossUp = nRSI Crosses Above oversold;
   crossDn = nRSI Crosses Below overbought;
}
plot sigUp = if !crossDn[1] and crossUp and !crossUp[1] then low else na;
plot sigDn = if !crossUp[1] and crossDn and !crossDn[1] then high else na;
sigUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
sigDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
sigUp.SetDefaultColor(Color.CYAN);
sigDn.SetDefaultColor(Color.MAGENTA);


AssignPriceColor(if !colorBars then Color.CURRENT else CreateColor(colR,colG, colB));

#-- END of CODE
 
Not to look the proverbial gift horse in the mouth: Quick question regarding the colors.

There is an orangish color I am seeing?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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