Display RSI label on ThinkorSwim?

M

Miket

Member
Does anyone have a RSI badge that you could put in your chart? thx
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
Give this a try:

Code:
def rsi = RSIWilder("over bought" = 95, "over sold" = 5, price = close(period = AggregationPeriod.FOUR_DAYS));
AddLabel(yes, rsi, if rsi >= 95 or rsi <= 5 then Color.RED else Color.WHITE);
Source
 
M

Miket

Member
Just a small black box. not sure how to fix it

Code:
# beginning of code ———————- –
# current ADX as a label at top of the chart
#
# Label color changes according to value of ADX:
# . Green if >25
# . Gray if 20 to 25
# . Red if < 20
# . Red if < 20 # input length = 14; plot currentADX = ADX(length); currentADX.hide();
input length = 14;
plot currentADX = ADX(length);
currentADX.hide();
DefineGlobalColor(“ADXHigh”, CreateColor(50, 205, 50));

DefineGlobalColor(“ADXLow”, Color.RED);
DefineGlobalColor(“ADXMid”, Color.GRAY);
AddLabel (yes, (Concat(“ADX = “, Round(currentADX,1))),if currentADX > 25 then GlobalColor(“ADXHigh”) else if currentADX < 20 then GlobalColor("ADXLow") else GlobalColor("ADXMid")); # end of code ——————————-
 
M

Miket

Member
I tried converting this this adx badge to rsi and failed. not sure if this would help
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
That code you sent is ADX. Your original question is for RSI.
 
H

horserider

Well-known member
VIP
Warehouse
Code:
# SimpleMovingAvg RSI label by Horsrider 10/10/2019

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;

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;

plot RSI = 50 * (ChgRatio + 1);

AddLabel(yes, rsi, if rsi >= over_Bought  or rsi <= over_Sold then Color.RED else Color.GREEN);
 
Branch

Branch

New member
I would like to have a label (AddLabel) that tells me that the RSI trending higher or lower based on the close. Something like an if statement.
If the OHLC4 RSI percentage is higher than the previous RSI percentage on the the OHLC4 close then"Higher" the label will show Higher and the color I want to be green. Note: I can handle the color part, I just need help with this if statement.

How can I get that thought in ThinkScript?
 
T

tomsk

Well-known member
VIP
Warehouse
@Branch Here is a simple label that compares two RSI values and displays whether the RSI is RISING or FALLING over n periods
I have color coded the label green, pink, and yellow

Code:
input n = 21;
def RSI_ = RSI(14, 70, 30, close, AverageType.WILDERS);
def RSIUP = RSI_ > RSI_[n];
def RSIDN = RSI_ < RSI_[n];
addlabel(1, "RSI : " + Round(RSI_,2) + (if RSIUP then " RISING [" + n + " BARS]"
                                        else if RSIDN then " FALLING [" + n + " BARS]"
                                        else " NEUTRAL"),
if RSIUP then Color.GREEN else if RSIDN then Color.PINK else Color.YELLOW);
 
Branch

Branch

New member
@tomsk - Perfect! Thanks for the code; this is what I was looking for. This is wonderful, I am going to put it to work this week.
 
zeek

zeek

Member
VIP
@horserider Is it possible to make the label only paint the label green if the RSI value goes below 30 and only paint red if the value goes above 70? If not, can the label be colored grey if the value is currently between 30 and 70?

Thanks for a great script!
 
mc01439

mc01439

Active member
VIP
Warehouse
@horserider Is it possible to make the label only paint the label green if the RSI value goes below 30 and only paint red if the value goes above 70? If not, can the label be colored grey if the value is currently between 30 and 70?

Thanks for a great script!
@zeek - Here you go - as requested.


Code:
input n = 21;
def RSI = RSI(14, 70, 30, close, AverageType.WILDERS);

def rsiUP = RSI < 30;
def rsiDN = RSI > 70;
def rsinet = !rsiUP and !rsiUP;

AddLabel(rsiUP, "  RSI < 30  ", Color.GREEN);
AddLabel(rsiDN, "  RSI > 70  ", Color.RED);
AddLabel(rsinet, " RSI between 30 & 70", Color.GRAY);
 
T

tomsk

Well-known member
VIP
Warehouse
@zeek per your request I have modified @horserider RSI label code to display the label GREEN is RSI goes below 30 and paint it RED if RSI goes above 70. Otherwise RSI is not displayed


# SimpleMovingAvg RSI label by Horsrider 10/10/2019

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;

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;

plot RSI = 50 * (ChgRatio + 1);

AddLabel(RSI < over_Sold or RSI > over_Bought, RSI, if RSI < over_Sold then Color.GREEN else Color.RED);
 

Top