Advertisement
JustUncleL

FX Sniper: T3-CCI Strategy revised by JustUncleL

Aug 7th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. //@version=3
  2. //
  3. study(title="FX Sniper: T3-CCI Strategy revised by JustUncleL", shorttitle="T3-CCI")
  4. //
  5. ////////////////////////////////////////////////////////////
  6. // Copyright by HPotter v1.0 10/04/2017
  7. // This simple indicator gives you a lot of useful information - when to enter, when to exit
  8. // and how to reduce risks by entering a trade on a double confirmed signal.
  9. // You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
  10. //
  11. // Added Alerts when signal changes.
  12. // Changed alerts to occur after candle completes: JustUncleL
  13. ////////////////////////////////////////////////////////////
  14. //
  15.  
  16. CCI_Period = input(14, minval=1)
  17. T3_Period = input(5, minval=1)
  18. b = input(0.618)
  19.  
  20. // Constants colours that include fully non-transparent option.
  21. green100 = #008000FF
  22. lime100 = #00FF00FF
  23. red100 = #FF0000FF
  24. blue100 = #0000FFFF
  25. aqua100 = #00FFFFFF
  26. darkred100 = #8B0000FF
  27. gray100 = #808080FF
  28.  
  29. hline(0, color=purple, linestyle=line)
  30. xPrice = close
  31. b2 = b*b
  32. b3 = b2*b
  33. c1 = -b3
  34. c2 = (3*(b2 + b3))
  35. c3 = -3*(2*b2 + b + b3)
  36. c4 = (1 + 3*b + b3 + 3*b2)
  37. nn = iff(T3_Period < 1, 1, T3_Period)
  38. nr = 1 + 0.5*(nn - 1)
  39. w1 = 2 / (nr + 1)
  40. w2 = 1 - w1
  41. xcci = cci(xPrice, CCI_Period)
  42. //Initialise look forward variables (version3 Pinescript)
  43. e1 = 0.0
  44. e2 = 0.0
  45. e3 = 0.0
  46. e4 = 0.0
  47. e5 = 0.0
  48. e6 = 0.0
  49. pos = 0
  50. //
  51. e1 := w1*xcci + w2*nz(e1[1])
  52. e2 := w1*e1 + w2*nz(e2[1])
  53. e3 := w1*e2 + w2*nz(e3[1])
  54. e4 := w1*e3 + w2*nz(e4[1])
  55. e5 := w1*e4 + w2*nz(e5[1])
  56. e6 := w1*e5 + w2*nz(e6[1])
  57. xccir = c1*e6 + c2*e5 + c3*e4 + c4*e3
  58. cciHcolor = iff(xccir >= 0 , green, iff(xccir < 0, red, black))
  59. pos := iff(xccir > 0, 1, iff(xccir < 0, -1, nz(pos[1], 0)))
  60. barcolor(pos == -1 ? red100: pos == 1 ? green100 : blue100 )
  61. buy = pos != pos[1] and pos == 1
  62. sell= pos != pos[1] and pos == -1
  63. alertcondition(buy[1] and barstate.isnew, title='Signal Changed', message="Buy")
  64. alertcondition(sell[1] and barstate.isnew, title='Signal Changed', message="Sell")
  65. //barcolor(pos == -1 ? red: pos == 1 ? green : blue ) // repeated
  66. plot(xccir, color=blue, title="T3-CCI")
  67. plot(xccir, color=cciHcolor, title="CCIH", style = histogram)
  68. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement