Untitled

mail@pastecode.io avatar
unknown
plain_text
4 months ago
4.0 kB
24
Indexable
//@version=5

indicator("RSI Extreme", overlay = true)

RSIEswitch  = input.bool (true, "RSI Extremes", group='Switch panel (Overlay indicators)', inline='S1')

G_RSIExtreme = "RSI EXTREME"

RSIPeriodExtreme = input.int(14, title='Period', step=1, minval=1, group=G_RSIExtreme, inline='RSIE1')
RSISourceExtreme = input(title='Source', defval=close, group=G_RSIExtreme, inline='RSIE')
RSIlabelSizeExtreme = input.string('Small', 'Label Size', options = ['Tiny', 'Small', 'Normal', 'Large'], group=G_RSIExtreme, inline='RSIE')
OversoldForRSIExtreme = input.int(30, title='Oversold Level', maxval=100, minval=1, step=1, group=G_RSIExtreme, inline='RSIE2')
OverboughtForRSIExtreme = input.int(70, title='Overbought Level', maxval=100, minval=1, step=1, group=G_RSIExtreme, inline='RSIE2')

RSIExtreme = ta.rsi(RSISourceExtreme, RSIPeriodExtreme)

sizerLabel = switch RSIlabelSizeExtreme
    'Normal'  => size.normal
    'Tiny'    => size.tiny
    'Small'   => size.small
    'Large'   => size.large

bool IsOversoldForRSIExtreme = false
bool IsOverboughtForRSIExtreme = false

if RSIExtreme <= OversoldForRSIExtreme and RSIEswitch
    label lup = label.new(bar_index, na, str.tostring(int(RSIExtreme)), color=color.new(color.lime, 0), textcolor=color.rgb(141, 141, 141), style=label.style_arrowup, size=sizerLabel, yloc=yloc.belowbar)
    IsOversoldForRSIExtreme := true
    if RSIExtreme <= OversoldForRSIExtreme and RSIExtreme[1] <= OversoldForRSIExtreme
        if low[1] > low
            if RSIExtreme[1] <= RSIExtreme 
                label.delete(lup[1])
        if low[1] > low
            if RSIExtreme[1] >= RSIExtreme 
                label.delete(lup[1])
        if low[1] < low        
            if RSIExtreme[1] >= RSIExtreme    
                label.delete(lup)
        if low[1] < low        
            if RSIExtreme[1] <= RSIExtreme    
                label.delete(lup)
    if RSIExtreme <= OversoldForRSIExtreme and RSIExtreme[2] <= OversoldForRSIExtreme
        if low[2] > low
            if RSIExtreme[2] <= RSIExtreme 
                label.delete(lup[2])
        if low[2] > low
            if RSIExtreme[2] >= RSIExtreme 
                label.delete(lup[2])
        if low[2] < low        
            if RSIExtreme[2] >= RSIExtreme    
                label.delete(lup)
        if low[2] < low        
            if RSIExtreme[2] <= RSIExtreme    
                label.delete(lup)                  

if RSIExtreme >= OverboughtForRSIExtreme and RSIEswitch
    label ldw = label.new(bar_index, na, str.tostring(int(RSIExtreme)), color=color.new(color.red, 0), textcolor=color.rgb(141, 141, 141), style=label.style_arrowdown, size=sizerLabel, yloc=yloc.abovebar)
    IsOverboughtForRSIExtreme := true
    if RSIExtreme >= OverboughtForRSIExtreme and RSIExtreme[1] >= OverboughtForRSIExtreme
        if high[1] < high
            if RSIExtreme[1] <= RSIExtreme 
                label.delete(ldw[1])
        if high[1] < high
            if RSIExtreme[1] >= RSIExtreme 
                label.delete(ldw[1])
        if high[1] > high        
            if RSIExtreme[1] >= RSIExtreme    
                label.delete(ldw)
        if high[1] > high        
            if RSIExtreme[1] <= RSIExtreme    
                label.delete(ldw)

    if RSIExtreme >= OverboughtForRSIExtreme and RSIExtreme[2] >= OverboughtForRSIExtreme
        if high[2] < high
            if RSIExtreme[2] <= RSIExtreme 
                label.delete(ldw[2])
        if high[2] < high
            if RSIExtreme[1] >= RSIExtreme 
                label.delete(ldw[2])
        if high[2] > high        
            if RSIExtreme[2] >= RSIExtreme    
                label.delete(ldw)
        if high[2] > high        
            if RSIExtreme[2] <= RSIExtreme    
                label.delete(ldw)

alertcondition(IsOversoldForRSIExtreme and IsOverboughtForRSIExtreme, 'Extreme RSI Overbought-Oversold Call', 'Extreme RSI Overbought-Oversold Call found')
Leave a Comment