0% found this document useful (0 votes)
12 views5 pages

Rsi Ob-Os

The document is a TradingView script for an RSI (Relative Strength Index) indicator that includes customizable parameters for different timeframes and visualizations of bullish and bearish signals. It plots the RSI values, overbought and oversold levels, and highlights regular and hidden bullish and bearish conditions based on price movements. Additionally, it includes alert functionalities for crossing over and under specified RSI levels.

Uploaded by

Atul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Rsi Ob-Os

The document is a TradingView script for an RSI (Relative Strength Index) indicator that includes customizable parameters for different timeframes and visualizations of bullish and bearish signals. It plots the RSI values, overbought and oversold levels, and highlights regular and hidden bullish and bearish conditions based on price movements. Additionally, it includes alert functionalities for crossing over and under specified RSI levels.

Uploaded by

Atul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

//@version=4

study(title="RSI OB-OS By Beyond", format=format.price, resolution="")

len = input(title="RSI Period", minval=1, defval=14)


src = input(title="RSI Source", defval=close)
lbR = input(title="Pivot Lookback Right", defval=5)
lbL = input(title="Pivot Lookback Left", defval=5)
rangeUpper = input(title="Max of Lookback Range", defval=60)
rangeLower = input(title="Min of Lookback Range", defval=5)
plotBull = input(title="Plot Bullish", defval=true)
plotHiddenBull = input(title="Plot Hidden Bullish", defval=false)
plotBear = input(title="Plot Bearish", defval=true)
plotHiddenBear = input(title="Plot Hidden Bearish", defval=false)
resa = input(title="Different Timeframe :", type=input.resolution, defval="D")
res = input(title="Different Timeframe :", type=input.resolution, defval="W")
res1 = input(title="Different Timeframe :", type=input.resolution, defval="M")

lengthM = input(title="LengthM", type=input.integer, defval=14, minval=1,


maxval=2000)
srcM = hlc3
upperM = sum(volume * (change(src) <= 0 ? 0 : src), lengthM)
lowerM = sum(volume * (change(src) >= 0 ? 0 : src), lengthM)
mfM = rsi(upperM, lowerM)
plot(mfM, title="MFM", color=#459915)

diftime = input(true, title="Show Different Timeframe ?")

bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
noneColor = color.new(color.white, 100)

osc = rsi(src, len)

rsia=diftime ? security(syminfo.tickerid, resa, osc) : na


rsiD1=plot(rsia, title="RSI", linewidth=2, color=#8D1699)

rsia1= security(syminfo.tickerid, res, osc)


rsia2= security(syminfo.tickerid, res1, osc)

plot(rsia1, title="RSI1", linewidth=2, color=#8D1699)


plot(rsia2, title="RSI2", linewidth=2, color=#8D1699)

hline(50, title="Middle Line", linestyle=hline.style_dotted)


obLevel = hline(70, title="Overbought", linestyle=hline.style_dotted)
osLevel = hline(30, title="Oversold", linestyle=hline.style_dotted)
obLeve2 = hline(90, title="Price Overbought", linestyle=hline.style_dotted)
osLeve2 = hline(20, title="price Oversold", linestyle=hline.style_dotted)
fill(obLevel, osLevel, title="Background", color=#9915FF, transp=90)

schW = rsia1 > 60


color.new(schW ? color.red : na, transp=60)
schM = rsia2 > 60
color.new(schM ? color.blue : na, transp=60)

plFound = na(pivotlow(osc, lbL, lbR)) ? false : true


phFound = na(pivothigh(osc, lbL, lbR)) ? false : true

_inRange(cond) =>
bars = barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper

i_oversold = input(defval = 70, title = "Oversold", minval = 1)


i_overbought = input(defval = 30, title = "Overbought", minval = 1)

f_osIn = crossover (osc, i_oversold)


f_osOut = crossunder (osc, i_oversold)
f_obIn = crossunder (osc, i_overbought)
f_obOut = crossover (osc, i_overbought)

// --------- Colors
c_orange = #f57f17 //Orange
c_green = #006400 //Green
c_green50 = #00640080//Green 50%
c_red = #8B0000 //Red
c_red50 = #8B000080//Red 50%
c_gray = #808080 //Gray

f_osCol = osc > i_oversold and osc >= osc[1] ? c_green50 :


osc > i_oversold and osc < osc[1] ? c_green :
osc < i_oversold and osc[1] > i_oversold ? c_green : na
f_obCol = osc < i_overbought and osc >= osc[1] ? c_red50 :
osc < i_overbought and osc < osc[1] ? c_red :
osc > i_overbought and osc[1] < i_overbought ? c_red : na

// --------- Plot
p_0 = plot(
osc,
title = "RSI",
color = c_orange)
p_1 = plot(
i_oversold,
title = "Oversold",
color = c_gray)
p_2 = plot(
i_overbought,
title = "Overbought",
color = c_gray)
fill(
p_1, p_0,
color = f_osCol,
transp = 5)
fill(
p_2, p_0,
color = f_obCol,
transp = 5)

// --------- Alerts
plot(
f_osIn ? i_oversold :
f_obIn ? i_overbought : na,
title = "RSI Over In",
color = c_orange,
linewidth = 3,
style = plot.style_circles)
plot(
f_osOut ? i_oversold :
f_obOut ? i_overbought : na,
title = "RSI Over Out",
color = c_orange,
linewidth = 4,
style = plot.style_circles)
fill(
p_1, p_2,
color = c_gray,
transp = 95)

//------------------------------------------------------------------------------
// Regular Bullish

// Osc: Higher Low


oscHL = osc[lbR] > valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])

// Price: Lower Low


priceLL = low[lbR] < valuewhen(plFound, low[lbR], 1)

bullCond = plotBull and priceLL and oscHL and plFound

plot(
plFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(bullCond ? bullColor : noneColor),
transp=0
)

plotshape(
bullCond ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text=" Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
transp=0
)

//------------------------------------------------------------------------------
// Hidden Bullish

// Osc: Lower Low


oscLL = osc[lbR] < valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])

// Price: Higher Low


priceHL = low[lbR] > valuewhen(plFound, low[lbR], 1)

hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound

plot(
plFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=2,
color=(hiddenBullCond ? hiddenBullColor : noneColor),
transp=0
)

plotshape(
hiddenBullCond ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text=" H Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
transp=0
)

//------------------------------------------------------------------------------
// Regular Bearish

// Osc: Lower High


oscLH = osc[lbR] < valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])

// Price: Higher High


priceHH = high[lbR] > valuewhen(phFound, high[lbR], 1)

bearCond = plotBear and priceHH and oscLH and phFound

plot(
phFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(bearCond ? bearColor : noneColor),
transp=0
)

plotshape(
bearCond ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text=" Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)

//------------------------------------------------------------------------------
// Hidden Bearish

// Osc: Higher High


oscHH = osc[lbR] > valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])

// Price: Lower High


priceLH = high[lbR] < valuewhen(phFound, high[lbR], 1)
hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound

plot(
phFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=2,
color=(hiddenBearCond ? hiddenBearColor : noneColor),
transp=0
)

plotshape(
hiddenBearCond ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text=" H Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)

You might also like