RSI Bands from the old days… Came across it again and revised it a little, as it used some of the old input commands.
HaasScript Code
-- ---------------------------------
-- Script: RSI Price Bands (https://www.tradingview.com/script/zmvOIVUw-RS-JR-RSI-Price-Bands/)
-- Ported by pshai
-- ---------------------------------
-- ||--------------------------------------------------------------------------------------------------------------------------||
-- ||--- INPUTS: --------------------------------------------------------------------------------------------------------||
-- ||--------------------------------------------------------------------------------------------------------------------------||
OptimizedForInterval(CurrentInterval(),
function()
local src = ClosePrices()
local showRSI1 = Input('1.1. Show RSI Line 1?', true)
local showRSI2 = Input('1.2. Show RSI Line 2?', true)
local showRSI3 = Input('1.3. Show RSI Line 3?', true)
local baseMA_length = Input('2. Bands Smoothness Period Length', 20)
local fast_rsi_length = Input('3.1. Fast RSI Period Length', 7)
local fast_smooth_length = Input('3.2. Fast RSI Smoothness Length', 1)
local medium_rsi_length = Input('4.1. Medium RSI Period Length', 21)
local medium_smooth_length = Input('4.2. Medium RSI Smoothness Length', 1)
local slow_rsi_length = Input('5.1. Slow RSI Period Length', 50)
local slow_smooth_length = Input('5.2. Slow RSI Smoothness Length', 1)
local deviation_length = Input('6. Bands Tightness Period Length', 2)
local showOBSFill = Input('7. Show Over Bought/Sold Bands?', true)
-- ||--------------------------------------------------------------------------------------------------------------------------||
local hh = GetHighs(src, baseMA_length)
local ll = GetLows(src, baseMA_length)
-- ||--------------------------------------------------------------------------------------------------------------------------||
-- ||--- RSI to Price level conversion: ---------------------------------------------------------------------------------||
-- ||--------------------------------------------------------------------------------------------------------------------------||
local baseMA = EMA(Average(hh,ll), 10) --ema(src, baseMA_length)
local capdev = Sum(STDDEV(src, deviation_length, 1)) / (Count(src)+1)
local fastRSI = RSI(src, fast_rsi_length)
if fast_smooth_length >= 3 then
fastRSI = EMA(fastRSI, fast_smooth_length)
end
local mediumRSI = RSI(src, medium_rsi_length)
if medium_smooth_length >= 3 then
mediumRSI = EMA(mediumRSI, medium_smooth_length)
end
local slowRSI = RSI(src, slow_rsi_length)
if slow_smooth_length >= 3 then
slowRSI = EMA(slowRSI, slow_smooth_length)
end
PlotHorizontalLine(1, '', Green, 30)
PlotHorizontalLine(1, '', DarkGray, 50)
PlotHorizontalLine(1, '', Red, 70)
Plot(1, 'Fast RSI', fastRSI, {c=Yellow})
Plot(1, 'Medium RSI', mediumRSI, {c=Cyan})
Plot(1, 'Slow RSI', slowRSI, {c=Purple})
ChartSetAxisOptions(1, RightAxis, {l=0,h=100})
local fastRSILine = baseMA[1] - (capdev*(50-fastRSI[1]))
local mediumRSILine = baseMA[1] - (capdev*(50-mediumRSI[1]))
local slowRSILine = baseMA[1] - (capdev*(50-slowRSI[1]))
local bl = Plot(0, 'Middle Line / RSI.50', baseMA, {c=DarkGray})
Plot(0, 'Fast RSI', fastRSILine, {c=Yellow})
Plot(0, 'Medium RSI', mediumRSILine, {c=Cyan})
Plot(0, 'Slow RSI', slowRSILine, {c=Purple})
-- ||--------------------------------------------------------------------------------------------------------------------------||
-- ||--- Over Bought/Sold Bands: ----------------------------------------------------------------------------------------||
-- ||--------------------------------------------------------------------------------------------------------------------------||
local OBLine = baseMA[1] + (capdev*20)
local OSLine = baseMA[1] - (capdev*20)
local ob1 = Plot(0, 'Over Bought Line', OBLine, {c=Red})
local os1 = Plot(0, 'Over Sold Line', OSLine, {c=Green})
PlotCircle(ob1, Black)
PlotCircle(os1, Black)
local ob2 = Plot(0, 'RSI.100 Line', baseMA[1] + (capdev*50), {c='rgb(128,0,0)'})
local os2 = Plot(0, 'RSI.0 Line', baseMA[1] - (capdev*50), {c=DarkGreen})
PlotCircle(ob2, Black)
PlotCircle(os2, Black)
PlotBands(ob1, ob2, ChangeColorOpacity(Red, 5))
PlotBands(os1, os2, ChangeColorOpacity(Green, 5))
end
)
Copy to Clipboard