Advertisement
periho

Trend following screener

Feb 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //--------------------- Trend following -----------------------------------
  2. //-1. First - W (weekly chart): Screening for settled trend in the range of 2 to 5 weeks in the past, window 2W to 5W (by 4 vs 8EMA).
  3. //-2. Secondly - D (Daily chart) Screening for settled trend in the range of 8 to 11 days (10 vs 20EMA).
  4. //-Option: Screen 4H chart for a trigger where Pris(namely Close) crossing 5 til 20EMA (4H).
  5. //-Option: Study parameters for setting of the MACD as an alternative
  6. //-Option: This cross over can be tested by Back testing and live trading in a Paper trading account first.
  7. //-------------------------------------------------------------------------
  8. //
  9. TIMEFRAME(Weekly)
  10. //
  11. //-Downtrend:
  12. indicator1 = ExponentialAverage[4](close)
  13. indicator2 = ExponentialAverage[8](close)
  14. //-Sjekker at 13W EMA > 3W EMA dvs. ned-trend
  15. c0 = (indicator1[2] < indicator2[2])
  16. c1 = (indicator1[3] < indicator2[3])
  17. c2 = (indicator1[4] < indicator2[4])
  18. c3 = (indicator1[5] < indicator2[5])
  19. //c4 = (indicator1[6] > indicator2[6])
  20. //
  21. DnTrendW = ( c0 and c1 and c2 and c3) //and c4 )
  22. //
  23. //-Uptrend:
  24. indicator10 = ExponentialAverage[4](close)
  25. indicator11 = ExponentialAverage[8](close)
  26. //
  27. //
  28. c10 = (indicator10[2] > indicator11[2])
  29. c11 = (indicator10[3] > indicator11[3])
  30. c12 = (indicator10[4] > indicator11[4])
  31. c13 = (indicator10[5] > indicator11[5])
  32. //c14 = (indicator10[6] > indicator20[6])
  33. //
  34. UpTrendW = ( c10 and c11 and c12 and c13) //and c4 )
  35. //-----------
  36. TIMEFRAME(Daily)
  37. //
  38. //-Downtrend:
  39. indicator3 = ExponentialAverage[20](close)
  40. indicator4 = ExponentialAverage[10](close)
  41. //
  42. c5 = (indicator3[8] > indicator4[8])
  43. c6 = (indicator3[9] > indicator4[9])
  44. c7 = (indicator3[10] > indicator4[10])
  45. c8 = (indicator3[11] > indicator4[11])
  46. //c9= (indicator3[9] > indicator4[9])
  47. //c10= (indicator3[10] > indicator4[10])
  48. //
  49. DnTrendD = ( c5 and c6 and c7 and c8) //and c9 and c10 )
  50. //
  51. //-Uptrend:
  52. indicator13 = ExponentialAverage[20](close)
  53. indicator14 = ExponentialAverage[10](close)
  54. //
  55. c15 = (indicator13[8] < indicator14[8])
  56. c16 = (indicator13[9] < indicator14[9])
  57. c17 = (indicator13[10] < indicator14[10])
  58. c18 = (indicator13[11] < indicator14[11])
  59. //c19= (indicator13[9] < indicator14[9])
  60. //c10= (indicator13[10] < indicator14[10])
  61. //
  62. UpTrendD = ( c15 and c16 and c17 and c18) //and c9 and c10 )
  63. //
  64. //TIMEFRAME(4 Hour)
  65. //
  66. indicator15 = ExponentialAverage[20](close)
  67. VZinDnTrend = (close > indicator15)
  68. VZinUpTrend = (close < indicator15)
  69. //
  70. TIMEFRAME(DEFAULT)
  71. //
  72. //-DownTrend
  73. If DnTrendW then
  74. if DnTrendD then
  75. if VZinDnTrend then
  76. myTrend = -1
  77. else
  78. myTrend = 0
  79. endif
  80. endif
  81. Endif
  82. //
  83. //-UpTrend
  84. If UpTrendW then
  85. if UpTrendD then
  86. if VZinUpTrend then
  87. myTrend = 1
  88. else
  89. myTrend = 0
  90.  
  91. endif
  92. endif
  93. Endif
  94. //-
  95. //-Summary
  96. //-
  97. If mytrend = 1 then
  98. Filter = 1
  99. Elsif myTrend = -1 then
  100. Filter = 1
  101. else
  102. Filter = 0
  103. endif
  104.  
  105.  
  106.  
  107. SCREENER[Filter] (myTrend AS "Lng.1|Sht.-1")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement