Advertisement
JustUncleL

FX Sniper: T3-CCI R2

Aug 9th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. //@version=3
  2. //
  3. study(title="FX Sniper: T3-CCI Strategy revision2 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. // Added Option to Wait for Candle Complete or Not.
  14. // Added Spike Alerts.
  15. ////////////////////////////////////////////////////////////
  16. //
  17.  
  18. CCI_Period = input(14, minval=1)
  19. T3_Period = input(5, minval=1)
  20. b = input(0.618)
  21. ofs = input(1,title="Delay Alert Offset (1=wait for candle close, 0=no wait)",minval=0,maxval=1)
  22.  
  23. // Constants colours that include fully non-transparent option.
  24. green100 = #008000FF
  25. lime100 = #00FF00FF
  26. red100 = #FF0000FF
  27. blue100 = #0000FFFF
  28. aqua100 = #00FFFFFF
  29. darkred100 = #8B0000FF
  30. gray100 = #808080FF
  31.  
  32. hline(0, color=purple, linestyle=line)
  33. xPrice = close
  34. b2 = b*b
  35. b3 = b2*b
  36. c1 = -b3
  37. c2 = (3*(b2 + b3))
  38. c3 = -3*(2*b2 + b + b3)
  39. c4 = (1 + 3*b + b3 + 3*b2)
  40. nn = iff(T3_Period < 1, 1, T3_Period)
  41. nr = 1 + 0.5*(nn - 1)
  42. w1 = 2 / (nr + 1)
  43. w2 = 1 - w1
  44. xcci = cci(xPrice, CCI_Period)
  45. //Initialise look forward variables (version3 Pinescript)
  46. e1 = 0.0
  47. e2 = 0.0
  48. e3 = 0.0
  49. e4 = 0.0
  50. e5 = 0.0
  51. e6 = 0.0
  52. pos = 0
  53. //
  54. e1 := w1*xcci + w2*nz(e1[1])
  55. e2 := w1*e1 + w2*nz(e2[1])
  56. e3 := w1*e2 + w2*nz(e3[1])
  57. e4 := w1*e3 + w2*nz(e4[1])
  58. e5 := w1*e4 + w2*nz(e5[1])
  59. e6 := w1*e5 + w2*nz(e6[1])
  60. xccir = c1*e6 + c2*e5 + c3*e4 + c4*e3
  61. cciHcolor = iff(xccir >= 0 , green, iff(xccir < 0, red, black))
  62. pos := iff(xccir > 0, 1, iff(xccir < 0, -1, nz(pos[1], 0)))
  63. barcolor(pos == -1 ? red100: pos == 1 ? green100 : blue100 )
  64. buy = pos != pos[1] and pos == 1
  65. sell= pos != pos[1] and pos == -1
  66. //alertcondition(buy[ofs] and barstate.isnew, title='Signal Buy', message="Buy")
  67. //alertcondition(sell[ofs] and barstate.isnew, title='Signal Sell', message="Sell")
  68. plot(buy[ofs]?200:0,color=green,title="Spike Long")
  69. plot(sell[ofs]?-200:0,color=red,title="Spike Short")
  70. //barcolor(pos == -1 ? red: pos == 1 ? green : blue ) // repeated
  71. plot(xccir, color=blue, title="T3-CCI")
  72. plot(xccir, color=cciHcolor, title="CCIH", style = histogram)
  73. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement