Advertisement
xmd79

Delta Zones Buy/Sell Pressure

Oct 18th, 2023
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. //@version=5
  2. indicator('Delta Zones Buy/Sell Pressure', overlay=true)
  3.  
  4. // Cálculo del Delta
  5. uptop = high - close
  6. upbot = open - low
  7. dntop = high - open
  8. dnbot = close - low
  9.  
  10. up_delta = upbot - uptop
  11. down_delta = dntop - dnbot
  12. delta = up_delta ? up_delta : down_delta ? down_delta : 0
  13.  
  14. pos_delta = delta > 0 ? delta : 0
  15. neg_delta = delta < 0 ? delta : 0
  16.  
  17. // Parámetros de desviación estándar
  18. stddevlevel = input.float(title='Standard Deviation', defval=3.0, step=0.5)
  19. stddevlookback = input(title='Standard Deviation Lookback', defval=20)
  20.  
  21. wickdevup = ta.stdev(pos_delta, stddevlookback) * stddevlevel
  22. wickdevdn = ta.stdev(neg_delta, stddevlookback) * -stddevlevel
  23.  
  24. huntingup = pos_delta >= wickdevup
  25. huntingdn = neg_delta <= wickdevdn
  26.  
  27. // Crear variables persistentes para las cajas
  28. var box buyBox = na
  29. var box sellBox = na
  30.  
  31. // Identificar y dibujar cajas para Buy Pressure
  32. if huntingup and open <= close // Velas Verdes con Buy Pressure
  33. buyBox := box.new(left=bar_index, top=(open + low) / 2,
  34. right=bar_index, bottom=low,
  35. bgcolor=color.new(#5d606b, 83),
  36. border_width=1, border_color=color.green)
  37.  
  38. if huntingup and open >= close // Velas Rojas con Buy Pressure
  39. buyBox := box.new(left=bar_index, top=(close + low) / 2,
  40. right=bar_index, bottom=low,
  41. bgcolor=color.new(#5d606b, 83),
  42. border_width=1, border_color=color.green)
  43.  
  44. // Ajustar la longitud de la caja si no hay nueva señal de Buy Pressure
  45. else
  46. box.set_right(id=buyBox, right=bar_index+5)
  47.  
  48. // Identificar y dibujar cajas para Sell Pressure
  49. if huntingdn and open < close // Velas Verdes con Sell Pressure
  50. sellBox := box.new(left=bar_index, top=high,
  51. right=bar_index, bottom=(close + high) / 2,
  52. bgcolor=color.new(#5d606b, 83),
  53. border_width=1, border_color=color.rgb(222, 11, 11))
  54.  
  55. if huntingdn and open > close // Velas Rojas con Sell Pressure
  56. sellBox := box.new(left=bar_index, top=high,
  57. right=bar_index, bottom=(open + high) / 2,
  58. bgcolor=color.new(#5d606b, 83),
  59. border_width=1, border_color=color.rgb(222, 11, 11))
  60.  
  61. // Ajustar la longitud de la caja si no hay nueva señal de Sell Pressure
  62. else
  63. box.set_right(id=sellBox, right=bar_index+5)
  64.  
  65. // Final del Script
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement