OTTinger

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
2
Indexable
//@version=5
indicator("Ottinger by YgtKgn&Hassonya", "Ottinger", overlay = true)

X1 = input(2, title="X1")
X2 = input(15, title="X2")
X3 = input(0.115, title="X3")
X4 = input(0.099, title="X4")

//var calculate function
Var_Func(src,length)=>
    valpha=2/(length+1)
    vud1=src>src[1] ? src-src[1] : 0
    vdd1=src<src[1] ? src[1]-src : 0
    vUD=math.sum(vud1,9)
    vDD=math.sum(vdd1,9)
    vCMO=nz((vUD-vDD)/(vUD+vDD))
    VAR=0.0
    VAR:=nz(valpha*math.abs(vCMO)*src)+(1-valpha*math.abs(vCMO))*nz(VAR[1])

//ott calculate function
Ott_Func(src, len, per) =>
    c1 = Var_Func(src, len)
    q1 = c1[2]*(1+per/200)
    q2 = c1[2]*(1-per/200)
    ott = 0.0
    ott := ta.cum(1)==1 ? c1 : q1<=nz(ott[1],0) ? q1 : q2>=nz(ott[1],0) ? q2 : ott[1]
    ott

x1PL = plot(Ott_Func(close, X1, X2)*(1+(X3*0.618)), color=color.orange)
x2PL = plot(Ott_Func(close, X1, X2)*(1+(X3*0.382)), color=color.orange)
fill(x1PL, x2PL, color=color.new(color.orange,50))

x3PL = plot(Ott_Func(close, X1, X2)*(1-(X4*0.618)), color=color.green)
x4PL = plot(Ott_Func(close, X1, X2)*(1-(X4*0.382)), color=color.green)
fill(x3PL, x4PL, color=color.new(color.green,50))
Leave a Comment