Advertisement
Guest User

Untitled

a guest
Jul 6th, 2016
1,673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. //@version=2
  2. //* COPY/PASTE THIS SCRIPT INTO YOUR TRADINGVIEW PINE EDITOR
  3. //* USE THIS SCRIPT TO MAKE EXCELLENT POSITION ENTRIES & EXITS!
  4.  
  5. study(title="Signals", shorttitle="Signals")
  6.  
  7. //Inputs
  8.  
  9. useCustomTick = input(false, title="Custom ticker? [Y/N]", confirm=true)
  10. tickCustom = input(title="Symbol [e.g. USDJPY]", type=string, defval="")
  11. useCustomRes = input(false, title="Custom time interval? [Y/N]", confirm=true)
  12. resCustom = input(title="Time interval (W, D, [min])", type=string, defval="")
  13. tickery = useCustomTick ? tickCustom : tickerid
  14. res = useCustomRes ? resCustom : period
  15. source = security(tickery, res, close)
  16.  
  17. length = input(21, minval=1, title="SIGNAL")
  18.  
  19.  
  20. //Williams%R + EMA
  21.  
  22. upper = highest(length)
  23. lower = lowest(length)
  24. out = 100 * (source - upper) / (upper - lower)
  25. src = out, len = input(13, minval=1, title="EMA")
  26. out2 = ema(out, len)
  27.  
  28.  
  29. //Inputs (2)
  30.  
  31. Sup = input(-20, minval=-100, title="Too Much UP")
  32. Sdown = input(-80, minval=-100, title="Too Much DOWN")
  33. HCross = input(defval=true, type = bool, title="Highlight crossovers? [Y/N]")
  34. Flex = input(3, minval=1, maxval=10, title="Cross flexibility [1-10]")
  35. BGcoloring = input(defval=true, type = bool, title="Background coloring? [Y/N]")
  36. Transpa = input(65, title="Background color transparency [%]")
  37.  
  38.  
  39. //Plot
  40.  
  41. band1 = hline(Sup, title="Band upperline", linestyle=dashed, linewidth=1, color= green)
  42. band0 = hline(Sdown, title="Band bottomline", linestyle=dashed, linewidth=1, color= red)
  43. top = hline(0, title="Top", linestyle=solid, linewidth=1, color= green)
  44. bottom = hline(-100, title="Bottom", linestyle=solid, linewidth=1, color= yellow)
  45. fill(band1, band0, color=white, transp=100, title="Inner band")
  46.  
  47. plot(out >= Sup ? 0 : na, title="overbought", color=#FF5050, style=cross, linewidth=5, transp=50)
  48. plot(out <= Sdown ? -100 : na, title="oversold", color=#99FF33, style=cross, linewidth=5, transp=50)
  49. plot((HCross and cross(out, out2) and out2 >= (Sup-Flex)) ? out2 : na,title="Overbought cross", color=red, style=circles, linewidth=10, transp=50)
  50. plot((HCross and cross(out, out2) and out2 <= (Sdown+Flex)) ? out2 : na,title="Oversold cross", color=#00FF00, style=circles, linewidth=10, transp=50)
  51.  
  52. Will = plot(out, title="Will", color=blue, linewidth=1)
  53. EMA = plot(out2, title="EMA", color=(out2[0]>out2[1]? green:red), linewidth=2)
  54.  
  55. plot((HCross and cross(out, out2) and out2 >= (Sup-Flex)) or (HCross and cross(out, out2) and out2 <= (Sdown+Flex))? out2 : na,title="Cross center", color=white, style=circles, linewidth=2, transp=80)
  56.  
  57. bgcolor(BGcoloring? (out2[0]>out2[1]? green:red) : na, transp=Transpa)
  58.  
  59. // counters for alert
  60. my_counter_up = input(0, title="Counter up")
  61. my_counter_down = input(0, title="Counter down")
  62.  
  63. my_counter_up = nz(my_counter_up[1])
  64. my_counter_down = nz(my_counter_down[1])
  65.  
  66. if (HCross and cross(out, out2) and out2 >= (Sup-Flex))
  67. my_counter_up := my_counter_up + 1
  68. else
  69. my_counter_down := 0
  70.  
  71. if (HCross and cross(out, out2) and out2 <= (Sdown+Flex))
  72. my_counter_down := my_counter_down + 1
  73. else
  74. my_counter_up := 0
  75.  
  76. alertcondition( my_counter_up >= 3, "Up 3 times", "SELL SELL" )
  77. alertcondition( my_counter_down >= 3, "Down 3 times", "BUY BUY" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement