Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © ysantur
- //@version=4
- study("ysantur Yeşillim", overlay = true)
- src = (close*2+high+low+open)/5
- depth = input(title="Depth", type=input.integer, defval=10)
- smooth = input(title="Smooth", type=input.integer, defval=9)
- bias = input(title="Bias", type=input.float, step=0.1, defval=0.3)
- up=(100+bias)/100
- down=(100-bias)/100
- f=array.new_int(depth+1)
- W=array.new_float(depth)
- a=1
- b=1
- sum=0.0
- for i=0 to depth
- array.set(f,i,a+b)
- a:=b
- b:=array.get(f,i)
- x=0.0
- for i=1 to depth-1
- array.set(W,i,array.get(f,depth-1)/array.get(f,i))
- sum:=sum+array.get(f,depth-1)/array.get(f,i)
- for i=1 to depth-1
- x:=x+array.get(W,depth-i) * src
- x:=x/sum
- x:=ema(x,8)
- y=ema(x,3)
- e1 = stdev(x, 3)
- e2 = stdev(x, 8)
- u=x+e1
- l=x-2*(e1+e2)
- buySignal = crossover(src, x)
- sellSignal = crossunder(src, y)
- //plotshape(buySignal,text="Buy",style=shape.labelup, size=size.tiny,color=color.green, textcolor=color.white)
- //plotshape(sellSignal,text="Sell",style=shape.labeldown, size=size.tiny,color=color.red, textcolor=color.white)
- renk=color.yellow
- if (crossover(src, x) or src>=x ) or src>=y
- renk:=color.green
- if (crossunder(src, y) or src<y)
- renk:=color.red
- plot(l,color=renk, linewidth=3)
- // Alerts
- // ***************************************************
- longCond = bool(na)
- shortCond = bool(na)
- longCond := crossover(src, x)
- shortCond := crossunder(src, y)
- CondIni = 0
- CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
- long = longCond and CondIni[1] == -1
- short = shortCond and CondIni[1] == 1
- plotshape(long, title="BUY", text="B", style=shape.labeldown, textcolor=color.white, size=size.auto, location=location.top, color=color.green, transp=0)
- plotshape(short, title="SELL", text="S", style=shape.labelup, textcolor=color.white, size=size.auto, location=location.bottom, color=color.red, transp=0)
- alertcondition(longCond, title="BUY", message="BUY")
- alertcondition(shortCond, title="SELL", message="SELL")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement