Advertisement
Igloro

Untitled

Mar 22nd, 2022
1,451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=5
  2. indicator("Doji detector", overlay=true)
  3.  
  4. ema_input = input(20, title="Ema")
  5. prev_p_1 = ta.ema(close, ema_input)
  6.  
  7. lowhigh_long_prop = input(10, title="Low / High proportion")
  8. body_prop_size = input(9, title="Body proportion size")
  9.  
  10. bar_size_h = high - close
  11. //body size
  12. bar_size_l = math.max(open, close) - math.min(close, open)
  13.  
  14. //size of whole with wicks
  15. body_size_h = high - low
  16.  
  17. //lowest wick size
  18. low_body_prop = close - low
  19.  
  20. //higher wick size
  21. high_body_prop = high - close
  22.  
  23. plot(prev_p_1)
  24.  
  25. body_size_proportion = input(2, title="Body size (X) times smaller than whole body")
  26. up_wick_size_proportion = input(2, title="Upper wick size (X) times bigger than body")
  27. down_wick_size_proportion = input(2, title="Lower wick size (X) times bigger than body")
  28.  
  29. is_doji_body = if body_size_h / body_size_proportion > bar_size_l
  30.     true
  31.  
  32. low_half_eq = if low_body_prop > bar_size_l * up_wick_size_proportion
  33.     true
  34. high_half_eq = if high_body_prop > bar_size_l * down_wick_size_proportion
  35.     true
  36. open_close_eq = if bar_size_l < body_size_h / body_prop_size
  37.     true
  38.    
  39. doji_star_up = if close <= prev_p_1 and open_close_eq and high_body_prop and  low_half_eq and is_doji_body
  40.     alert(message='Doji grave')
  41.     true
  42. doji_star_down = if close > prev_p_1 and open_close_eq and high_body_prop and  low_half_eq and is_doji_body
  43.     alert(message='Doji down')
  44.     true
  45.  
  46.  
  47.  
  48. plotshape(doji_star_up, style=shape.arrowup, color=color.green, location=location.belowbar, size=size.large, text="Doji star")
  49. plotshape(doji_star_down, style=shape.arrowdown, color=color.red, location=location.abovebar, size=size.large, text="Doji star")
  50.  
  51.  
  52. long_high_body = if high_body_prop > bar_size_l * lowhigh_long_prop
  53.     true
  54. open_low_eq = if (close - low) < body_size_h / body_prop_size
  55.     true
  56. doji_grave = if close > prev_p_1 and open_close_eq and open_low_eq and long_high_body
  57.     alert(message='Doji grave')
  58.     true
  59.    
  60.  
  61.  
  62. plotshape(doji_grave, style=shape.arrowdown, color=color.red, location=location.abovebar, size=size.large, text="Doji grave")
  63.  
  64. long_low_body = if low_body_prop > bar_size_l * lowhigh_long_prop
  65.     true
  66.    
  67. open_high_eq = if (high - close) < body_size_h / body_prop_size
  68.     true
  69.    
  70. doji_dragonfly = if close <= prev_p_1 and open_close_eq and open_high_eq and long_low_body
  71.     alert(message='Doji dragonfly')
  72.     true
  73.  
  74.  
  75. plotshape(doji_dragonfly, style=shape.arrowup, color=color.green, location=location.belowbar, size=size.large, text="Doji dragonfly")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement