Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @version=4
- // This source code is subject to the terms of the Mozilla Public License 2.0 https://mozilla.org/MPL/2.0/
- // ©mvs1231 || xxattaxx
- study("Quick-Glance RSI", shorttitle="QuickRSI",overlay=true)
- //Inputs
- RSI_Len = input(14, "RSI Length(14)", maxval=150)
- OB = input(70.0, "Overought Level(70)", minval=0, maxval=100)
- OS = input(30.0, "Oversold Levels(70)", minval=0, maxval=100)
- Offset = input(10, "Scale Offset(10)")
- eScale = input(true, "Show Scale 0-100?")
- eLine = input(true, "Show RSI Line?")
- eBox = input(true, "Show OB/OS box?")
- eLive = input(true, "Realtime?")
- //Workaround: function to prevent dropping last two zeros
- fstring(x) =>
- curr = str.format("{0,number,currency}", x)
- number = str.split(curr,"$")
- fstring = array.get(number,0)
- RSI = rsi(close, RSI_Len)
- //Scale for RSI Length
- HH = highest(high,RSI_Len)
- LL = lowest(low,RSI_Len)
- Range = HH - LL
- //Calculate RSI on overlay
- chartRSI = LL + (RSI / 100) * Range
- chartOS = LL + OS/100 * Range
- chartOB = LL + OB/100 * Range
- //Set colors
- obtext = color.new(color.lime,5)
- ostext = color.new(color.red,5)
- nntext = color.new(color.white,5)
- obbgr = color.new(color.maroon,80)
- osbgr = color.new(color.green,80)
- nnbgr = color.new(color.white,95)
- Plagueis = "Damask"
- rsicolor = RSI >= OB? obtext : RSI <= OS ? ostext : nntext
- darkcolor = RSI >= OB? obbgr : RSI <= OS ? osbgr : nnbgr
- //Draw lines/boxes
- line rsiLine = na
- label rsiLabel = na
- box obBox = na
- box osBox = na
- //scale labels
- label label100 = na
- label labelOB = na
- label label50 = na
- label labelOS = na
- label label0 = na
- //Enable Realtime or Delayed Calculations
- DrawNow = (eLive and barstate.isrealtime) or (not eLive and barstate.isconfirmed)
- //convert RSI to string and keep zeros after decimal
- fRSI = fstring(RSI)
- if DrawNow
- //Draw RSI Label
- rsitext = fRSI // + " (RSI " + tostring(RSI_Len) + ")"
- rsiLabel := label.new(bar_index + 2,chartRSI,text=rsitext,style=label.style_label_left,textcolor=rsicolor,color=darkcolor)
- // Draw RSI line
- if eLine
- rsiLine := line.new(bar_index-RSI_Len, chartRSI, bar_index + 2 , chartRSI, color=color.new(color.blue,20), extend=extend.none,
- style=line.style_solid, width=3)
- //Draw OB/OS box
- if eBox
- obBox := box.new(bar_index-RSI_Len,HH,bar_index + Offset,chartOB,bgcolor=obbgr,border_color=na)
- osBox := box.new(bar_index-RSI_Len,LL,bar_index + Offset,chartOS,bgcolor=osbgr,border_color=na)
- //Show 0-100 scale
- if eScale
- label100 := label.new(bar_index + Offset , HH, text="100",style=label.style_label_left,textcolor=nntext,color=na, size=size.tiny)
- labelOB := label.new(bar_index + Offset , chartOB, text=tostring(OB),style=label.style_label_left,textcolor=nntext,color=na, size=size.tiny)
- label50 := label.new(bar_index + Offset , LL + Range/2, text="50",style=label.style_label_left,textcolor=nntext,color=na, size=size.tiny)
- labelOS := label.new(bar_index + Offset , chartOS, text=tostring(OS),style=label.style_label_left,textcolor=nntext,color=na, size=size.tiny)
- label0 := label.new(bar_index + Offset , LL, text="0",style=label.style_label_left,textcolor=nntext,color=na, size=size.tiny)
- //Delete previous lines/boxes
- line.delete(rsiLine[1]), label.delete(rsiLabel[1]), label.delete(label100[1]), label.delete(labelOB[1])
- label.delete(label50[1]), label.delete(labelOS[1]), label.delete(label0[1])
- box.delete(obBox[1]), box.delete(osBox[1])
Advertisement
Add Comment
Please, Sign In to add comment