Advertisement
xmd79

Gann medians entry/exit targets

Aug 7th, 2022
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 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. // © DarkPoolTrading
  3. // Based on the Function Sine Wave Indicator by RicardoSantos
  4.  
  5. //@version=5
  6. indicator(title='Gann medians entry/exit targets', precision=12)
  7.  
  8. method1 = input.string('Median', options=['EMA', 'Median', 'SMA'])
  9. length1 = input(5)
  10. mult1 = input.int(1, minval=0, maxval=1)
  11.  
  12. method2 = input.string('Median', options=['EMA', 'Median', 'SMA'])
  13. length2 = input(7)
  14. mult2 = input.int(1, minval=0, maxval=1)
  15.  
  16. method3 = input.string('Median', options=['EMA', 'Median', 'SMA'])
  17. length3 = input(9)
  18. mult3 = input.int(1, minval=0, maxval=1)
  19. //----
  20. Avg(x, length, method) =>
  21. sma_1 = ta.sma(x, length)
  22. ema_1 = ta.ema(x, length)
  23. percentile_linear_interpolation_1 = ta.percentile_linear_interpolation(x, length, 50)
  24. method == 'SMA' ? sma_1 : method == 'EMA' ? ema_1 : percentile_linear_interpolation_1
  25. //----
  26. a1 = ta.highest(length1) - math.max(close, open)
  27. b1 = math.min(close, open) - ta.lowest(length1)
  28. c1 = math.max(close, open) + a1 * mult1
  29. d1 = math.min(close, open) - b1 * mult1
  30.  
  31. a2 = ta.highest(length2) - math.max(close, open)
  32. b2 = math.min(close, open) - ta.lowest(length2)
  33. c2 = math.max(close, open) + a2 * mult2
  34. d2 = math.min(close, open) - b2 * mult2
  35.  
  36. a3 = ta.highest(length3) - math.max(close, open)
  37. b3 = math.min(close, open) - ta.lowest(length3)
  38. c3 = math.max(close, open) + a3 * mult3
  39. d3 = math.min(close, open) - b3 * mult3
  40. //----
  41. e1 = Avg(c1, length1, method1)
  42. f1 = Avg(d1, length1, method1)
  43. g1 = 0
  44. cross_1 = ta.cross(close, f1)
  45. g1 := ta.cross(close, e1) ? 1 : cross_1 ? 0 : nz(g1[1])
  46.  
  47. e2 = Avg(c2, length2, method2)
  48. f2 = Avg(d2, length2, method2)
  49. g2 = 0
  50. cross_2 = ta.cross(close, f2)
  51. g2 := ta.cross(close, e2) ? 1 : cross_2 ? 0 : nz(g2[1])
  52.  
  53. e3 = Avg(c3, length3, method3)
  54. f3 = Avg(d3, length3, method3)
  55. g3 = 0
  56. cross_3 = ta.cross(close, f3)
  57. g3 := ta.cross(close, e3) ? 1 : cross_3 ? 0 : nz(g3[1])
  58. //---
  59. hilo1 = g1 * f1 + (1 - g1) * e1
  60. css1 = g1 == 1 ? color.green : color.red
  61. plot(hilo1, color=css1, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  62.  
  63. hilo2 = g2 * f2 + (1 - g2) * e2
  64. css2 = g2 == 1 ? color.green : color.red
  65. plot(hilo2, color=css2, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  66.  
  67. hilo3 = g3 * f3 + (1 - g3) * e3
  68. css3 = g3 == 1 ? color.green : color.red
  69. plot(hilo3, color=css3, style=plot.style_line, show_last=1, linewidth=1, trackprice=true, transp=0)
  70.  
  71.  
  72. //end of this part
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement