Advertisement
Guest User

Untitled

a guest
Jun 18th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © ysantur
  3.  
  4. //@version=4
  5. study("ysantur Yeşillim", overlay = true)
  6.  
  7.  
  8. src = (close*2+high+low+open)/5
  9. depth = input(title="Depth", type=input.integer, defval=10)
  10. smooth = input(title="Smooth", type=input.integer, defval=9)
  11.  
  12. bias = input(title="Bias", type=input.float, step=0.1, defval=0.3)
  13. up=(100+bias)/100
  14. down=(100-bias)/100
  15.  
  16. f=array.new_int(depth+1)
  17. W=array.new_float(depth)
  18. a=1
  19. b=1
  20. sum=0.0
  21.  
  22. for i=0 to depth
  23. array.set(f,i,a+b)
  24. a:=b
  25. b:=array.get(f,i)
  26.  
  27. x=0.0
  28.  
  29. for i=1 to depth-1
  30. array.set(W,i,array.get(f,depth-1)/array.get(f,i))
  31. sum:=sum+array.get(f,depth-1)/array.get(f,i)
  32.  
  33. for i=1 to depth-1
  34. x:=x+array.get(W,depth-i) * src
  35.  
  36. x:=x/sum
  37.  
  38. x:=ema(x,8)
  39. y=ema(x,3)
  40. e1 = stdev(x, 3)
  41. e2 = stdev(x, 8)
  42.  
  43. u=x+e1
  44. l=x-2*(e1+e2)
  45.  
  46.  
  47. buySignal = crossover(src, x)
  48. sellSignal = crossunder(src, y)
  49. //plotshape(buySignal,text="Buy",style=shape.labelup, size=size.tiny,color=color.green, textcolor=color.white)
  50. //plotshape(sellSignal,text="Sell",style=shape.labeldown, size=size.tiny,color=color.red, textcolor=color.white)
  51.  
  52. renk=color.yellow
  53. if (crossover(src, x) or src>=x ) or src>=y
  54. renk:=color.green
  55. if (crossunder(src, y) or src<y)
  56. renk:=color.red
  57.  
  58. plot(l,color=renk, linewidth=3)
  59.  
  60.  
  61. // Alerts
  62. // ***************************************************
  63. longCond = bool(na)
  64. shortCond = bool(na)
  65.  
  66. longCond := crossover(src, x)
  67. shortCond := crossunder(src, y)
  68.  
  69. CondIni = 0
  70. CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
  71. long = longCond and CondIni[1] == -1
  72. short = shortCond and CondIni[1] == 1
  73. plotshape(long, title="BUY", text="B", style=shape.labeldown, textcolor=color.white, size=size.auto, location=location.top, color=color.green, transp=0)
  74. plotshape(short, title="SELL", text="S", style=shape.labelup, textcolor=color.white, size=size.auto, location=location.bottom, color=color.red, transp=0)
  75. alertcondition(longCond, title="BUY", message="BUY")
  76. alertcondition(shortCond, title="SELL", message="SELL")
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement