volume rsi strategy by pro trader123
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © VSlip

//@version=5
strategy("My script",overlay=true)
highestvol= ta.highest(volume,10)
highestvol5= ta.highest(volume,5)
rsiSourceInput = input.source(close)
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), 14)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), 14)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiema= ta.sma(rsi,14)
takeprofit = (rsiema>rsi and rsi>50) or (rsiema>rsi and rsiema>50)
takeprofitshort= (rsiema<rsi and rsi<50) or (rsiema<rsi and rsiema<50)
notintrade=strategy.position_size<=0
a = 0
if(rsi<30)
    a := 1
if(a[1]==1 and 30<rsi)
    a:= 2
e=0
if(a==2 and rsiema>rsi)
    e:=1
if(a==2 and rsiema<rsi)
    e:=2
if(e[1]==1 and rsiema>rsi)
    e:=1
if(e[1]==1 and rsiema<rsi)
    e:=2
if(e[1]==2 and rsiema<rsi)
    e:=2
if(e[1]==2 and rsiema>rsi)
    e:=3
f=0
if(a==2 and rsiema<rsi)
    f:=1
if(a==2 and rsiema>rsi)
    f:=2
if(f[1]==1 and rsiema<rsi)
    f:=1
if(f[1]==1 and rsiema>rsi)
    f:=2
if(f[1]==2 and rsiema>rsi)
    f:=2
if(f[1]==2 and rsiema<rsi)
    f:=3
b = 0
if(rsi>70)
    b := 1
if(b[1]==1 and rsi<70)
    b:= 2
c=0
if(highestvol5==highestvol and rsi<30)
    c:=1
if(c[1]==1 and rsi[1]<30)
    c:=1
d=0
if(highestvol5==highestvol and rsi>70)
    d:=1
if(d[1]==1 and rsi[1]>70)
    d:=1

if(a==2 and c==1)
    strategy.entry("long",strategy.long)
    strategy.exit("long",loss = 30)
if(e==3)
    strategy.close("long",when = e==3)
if(b==2 and d==1)
    strategy.entry("short",strategy.short)
    strategy.exit("short", loss = 30)
if(f==3)
    strategy.close("short",when = f==3)
plot(e)