Thanks script works great!!!is there a way to modify it to show the 1hr RSI....on all my charts? I did something similar for ATR chart label.
i did this but the value is not coming up correctly
input BasePeriod = AggregationPeriod.HOUR;
input showlabel = yes;
def rsi = reference RSI("over bought" = 70, "over sold" = 30, price = close(period = AggregationPeriod.FOUR_DAYS));
AddLabel(yes, (Concat("RSI: ", Round(rsi, 2))), if rsi >= 70 then Color.RED else if rsi <= 30 then Color.GREEN else Color.WHITE);
# RSIrangelabel_01
# ---------------------
# halcyonguy
# 21-06-16
#
# ---- study rules ----
# RSI rising,
# RSI above 50 and higher than all 3 prev candles
# RSI falling,
# RSI below 50 and lower than all 3 prev candles
# -----------------------------------------
# ----------------------------------------
# copy relevant RSI code from TD study
# RSI
input length = 21;
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;
def RSI_ = 50 * (ChgRatio + 1);
# -----------------------------
def mid = 50;
def RSIabove = (RSI_ > mid);
def RSIbelow = (RSI_ < mid);
input compare_prev_bars = 3;
def rsihighest = highest(rsi_[1], compare_prev_bars);
def rsilowest = lowest(rsi_[1], compare_prev_bars);
def rsihigherprev = ( rsi_ > rsihighest );
def rsilowerprev = ( rsi_ < rsilowest );
def rsiup = rsiabove and rsihigherprev;
def RSIdn = rsibelow and rsilowerprev;
addlabel(1, "RSI : " + Round(RSI_,2) + (if RSIUP then " RISING"
else if RSIDN then " FALLING"
else " NEUTRAL"),
if RSIUP then Color.GREEN else if RSIDN then Color.RED else Color.YELLOW);
# --------------------------------
# test data
input show_hi_low_label = no;
addlabel(show_hi_low_label , "highest " + rsihighest + " lowest " + rsilowest , color.yellow);
addlabel(show_hi_low_label , rsi_ , color.yellow);
#
# RSIrangelabel_02
# -----------------------------------------
# halcyonguy
# 21-06-16
# v02 , checks series of RSI values, to see if prev is < next , or the opposite
# ---- study rules ----
# RSI rising,
# ....RSI above 50
# ....AND for the previous x RSI values, the previous value is < the next. a series of increasing values
# ......option to show arrows when this happens
#
# RSI falling,
# ....RSI below 50
# ....AND for the previous x RSI values, the previous value is > the next. a series of decreasing values
# ......option to show arrows when this happens
# -----------------------------------------
def na = double.nan;
# ----------------------------------------
# copy relevent RSI code from TD study
# RSI
input length = 21;
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;
def RSI_ = 50 * (ChgRatio + 1);
# -----------------------------
def mid = 50;
def RSIabove = (RSI_ > mid);
def RSIbelow = (RSI_ < mid);
input compare_prev_bars = 3;
# check if the prev x bars had increasing values
# count each RSI that is bigger than the previous
def upcnt = fold i = 0 to compare_prev_bars
with p
do p + ( if getvalue(rsi_, i) > getvalue(rsi_, i+1) then 1 else 0 );
# if the fold number matches compare_prev_bars, then all the bars are increasing
def upmatch = ( upcnt == compare_prev_bars);
# check if the prev x bars had decreasing values
# count each RSI that is smaller than the previous
def dwncnt = fold k = 0 to compare_prev_bars
with q
do q + ( if getvalue(rsi_, k) < getvalue(rsi_, k+1) then 1 else 0 );
# if the fold number matches compare_prev_bars, then all the bars are decreasing
def dwnmatch = ( dwncnt == compare_prev_bars);
def rsihighest = highest(rsi_[1], compare_prev_bars);
def rsilowest = lowest(rsi_[1], compare_prev_bars);
def rsihigherprev = ( rsi_ > rsihighest and upmatch);
def rsilowerprev = ( rsi_ < rsilowest and dwnmatch);
def rsiup = rsiabove and rsihigherprev;
def RSIdn = rsibelow and rsilowerprev;
addlabel(1, "RSI : " + Round(RSI_, 2) + (if RSIUP then " RISING"
else if RSIDN then " FALLING"
else " NEUTRAL") + (" over " + compare_prev_bars + " bars"),
if RSIUP then Color.GREEN else if RSIDN then Color.RED else Color.YELLOW);
# --------------------------------
# test data
input arrows_incr_or_decr_series_of_RSI = yes;
plot upmatch2 = if arrows_incr_or_decr_series_of_RSI then upmatch else na;
upmatch2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upmatch2.SetDefaultColor(Color.white);
plot dwnmatch2 = if arrows_incr_or_decr_series_of_RSI then dwnmatch else na;
dwnmatch2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
dwnmatch2.SetDefaultColor(Color.white);
input show_hi_low_label = no;
addlabel(show_hi_low_label , "highest " + rsihighest + " lowest " + rsilowest , color.yellow);
addlabel(show_hi_low_label, "upcnt " + upcnt + " / prevbar " + compare_prev_bars, if upmatch then color.green else color.magenta);
input show_rsi_values_below_candles = no;
plot rsival = if show_rsi_values_below_candles then rsi_ else na;
rsival.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
#
def rsi = reference RSI()."RSI" ;
AddLabel(rsi crosses below 35 or rsi crosses above 65,
if rsi crosses below 35 then "Buy" else
if rsi crosses above 65 then "Sell" else " ",
if rsi crosses below 35 then color.green else
if rsi crosses above 65 then color.red else color.gray);
Alert( rsi crosses below 35, "Buy" , Alert.Bar, Sound.Bell);
Alert( rsi crosses above 65, "Sell" , Alert.Bar, Sound.Bell);
input below = 35;
input above = 65;
def rsi = reference RSI()."RSI" ;
AddLabel(rsi crosses below (below) or rsi crosses above (above),
if rsi crosses below (below) then "Buy" else
if rsi crosses above (above) then "Sell" else " ",
if rsi crosses below (below) then color.green else
if rsi crosses above (above) then color.red else color.gray);
Alert( rsi crosses below (below), "Buy" , Alert.Bar, Sound.Bell);
Alert( rsi crosses above (above), "Sell" , Alert.Bar, Sound.Bell);
Hello, I was looking for an RSI label posted on chart with the RSI number as it's moving. Doesn't have to change colors or give buy or sell. Yellow lable would be nice. I don't have coding experience, but checking out this post and looking to see if I can create one. Any help would be appreciated. From that code, I could probably figure out how to make other labels stay on my charts. Top left.
#RSI_Label
input showRSI = yes;
input rsiLength = 14;
input rsiOverBought = 70;
input rsiOverSold = 30;
input rsiPrice = close;
input rsiAverageType = AverageType.WILDERS;
input rsiShowBreakouts = no;
def rsi = Round(RSI(rsiLength, rsiOverBought, rsiOverSold, rsiPrice, rsiAverageType), 0);
#AddLabel(showRSI, "RSI: " + rsi, if rsi < rsiOverSold then Color.CYAN else if rsi > rsiOverBought then Color.LIGHT_RED else Color.WHITE);
AddLabel(showRSI, "RSI: " + rsi, Color.YELLOW
#RSI Indicator w/ arrows, label, & alerts when price is below SMA100
input OB = 65;
input OS = 35;
input rsi_length = 14 ;
input showLabel = yes ;
def rsi = reference RSI("length" = 14)."RSI" ;
plot avg100 = MovingAverage(AverageType.SIMPLE, close, 100);
avg100.SetDefaultColor(color.violet);
plot UpArrow =
if rsi is less than OS and
close is less than avg100 then low else double.NaN ;
UpArrow .SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow .SetLineWeight(1);
UpArrow .SetDefaultColor(color.blue) ;
plot DownArrow = if rsi > OB then high else double.NaN ;
DownArrow .SetPaintingStrategy(PaintingStrategy.ARROW_down);
DownArrow .SetLineWeight(1);
DownArrow .SetDefaultColor(color.magenta) ;
AddLabel(showLabel,
if rsi is less than OS and
close is less than avg100 then "Buy" else
if rsi > OB then "Sell" else "RSI: " +round(rsi,1),
if rsi is less than OS and
close is less than avg100 then color.green else
if rsi > OB then color.red else color.gray);
Alert( rsi is less than OS and
close is less than avg100, "Buy" , Alert.Bar, Sound.Bell);
Alert( rsi > OB , "Sell" , Alert.Bar, Sound.Bell);
def rsiAbove = RSI()."RSI" is greater than RSI()."OverBought" ;
def rsiBelow = RSI()."RSI" is less than RSI()."OverSold";
plot value = if rsiAbove then 1 else if rsiBelow then -1 else 0;
Assignbackgroundcolor(if value == 1 then Color.Orange else if value == -1 then color.Green else color.current);
value.assignValuecolor(if value == 0 then color.current else color.black);
This is for a watchlist. I tried add label but not working
def rsiAbove = RSI()."RSI" is greater than RSI()."OverBought" ;
def rsiBelow = RSI()."RSI" is less than RSI()."OverSold";
plot value = if rsiAbove then 1 else if rsiBelow then -1 else 0;
value.Hide();
AddLabel(yes, if value == 1 then "OB" else if value == -1 then "OS" else " ", Color.BLACK);
AssignBackgroundColor(if value == 1 then Color.Orange else if value == -1 then color.Green else color.current);
This code is just what I was looking for to display a badge/label on my chart.@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);
Hi Ben, how can we move the bubble to the right of the chart?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
This is a lower study that you can move to the upper price pane, uncheck enable left axis, and choose whether to show or not the label and/or bubble. You can move the bubble sideways and or up and down. You can hide the plots that are necessary by setting their color to that of the chart background.Hi Ben, how can we move the bubble to the right of the chart?
also how to add bubble on a line? Thanks,
Ruby:input agg = AggregationPeriod.FOUR_DAYS; input showlabel = yes; input showbubble = yes; def rsi = reference RSI("over bought" = 95, "over sold" = 5, price = close(period = agg)); AddLabel(showlabel, rsi, if rsi >= 95 or rsi <= 5 then Color.RED else Color.WHITE); declare lower; plot top = 100; plot bottom = 0; top.SetDefaultColor(Color.GRAY); bottom.SetDefaultColor(Color.GRAY); input bubblemover_sideways = 5; input bubblemover_updown = 0; def b = bubblemover_sideways; def b1 = b + 1; AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), top[b] + bubblemover_updown, rsi[b1], if rsi[b1] >= 95 or rsi[b1] <= 5 then Color.RED else Color.WHITE, no);
##### Begin Code #####
# SD_RSILabel
# Scott D#####
# Version: 05
# Original: November 14, 2020
# Last Mod: December 14, 2020
declare upper;
input length = 14;
input RSIOverbought = 70;
input RSIOversold = 30;
input RSIPos = 60;
input RSINeg = 40;
input median = 50;
input RSI_to_Median = yes;
input RSI_Warning = yes;
input Spacer = yes;
# input AlertHiLevel = 70;
# input AlertLoLevel = 30;
def RSIlabel = reference RSI(length,price = close);
#spacer
addlabel(Spacer, " ", color.BLACK);
AddLabel(yes, if RSIlabel > RSIlabel[1] then " RSI RISING " else " RSI FALLING ", if RSIlabel > RSIlabel[1] then Color.GREEN else Color.RED);
AddLabel(yes, if RSIlabel >= RSIOverbought then " RSI OVERBOUGHT " else "", Color.RED);
AddLabel(yes, if RSIlabel <= RSIOversold then " RSI OVERSOLD " else "", Color.GREEN);
AddLabel(RSI_Warning, if RSIlabel >= RSIPos then " RSI HIGH WARNING " else "", Color.RED);
AddLabel(RSI_Warning, if RSIlabel <= RSINeg then " RSI LOW WARNING " else "", Color.GREEN);
AddLabel(RSI_to_Median, " RSI TO MEDIAN " + Round(RSILabel,0) + " ", if RSIlabel > median then Color.LIME else if RSIlabel <= median then Color.ORANGE else Color.WHITE);
# Alert(RSILabel > AlertHiLevel, "", Alert.Bar, Sound.Ring);
# Alert(RSILabel < AlertLoLevel, "", Alert.Bar, Sound.Ring);
##### End Code #####
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.