Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator('Delta Zones Buy/Sell Pressure', overlay=true)
- // Cálculo del Delta
- uptop = high - close
- upbot = open - low
- dntop = high - open
- dnbot = close - low
- up_delta = upbot - uptop
- down_delta = dntop - dnbot
- delta = up_delta ? up_delta : down_delta ? down_delta : 0
- pos_delta = delta > 0 ? delta : 0
- neg_delta = delta < 0 ? delta : 0
- // Parámetros de desviación estándar
- stddevlevel = input.float(title='Standard Deviation', defval=3.0, step=0.5)
- stddevlookback = input(title='Standard Deviation Lookback', defval=20)
- wickdevup = ta.stdev(pos_delta, stddevlookback) * stddevlevel
- wickdevdn = ta.stdev(neg_delta, stddevlookback) * -stddevlevel
- huntingup = pos_delta >= wickdevup
- huntingdn = neg_delta <= wickdevdn
- // Crear variables persistentes para las cajas
- var box buyBox = na
- var box sellBox = na
- // Identificar y dibujar cajas para Buy Pressure
- if huntingup and open <= close // Velas Verdes con Buy Pressure
- buyBox := box.new(left=bar_index, top=(open + low) / 2,
- right=bar_index, bottom=low,
- bgcolor=color.new(#5d606b, 83),
- border_width=1, border_color=color.green)
- if huntingup and open >= close // Velas Rojas con Buy Pressure
- buyBox := box.new(left=bar_index, top=(close + low) / 2,
- right=bar_index, bottom=low,
- bgcolor=color.new(#5d606b, 83),
- border_width=1, border_color=color.green)
- // Ajustar la longitud de la caja si no hay nueva señal de Buy Pressure
- else
- box.set_right(id=buyBox, right=bar_index+5)
- // Identificar y dibujar cajas para Sell Pressure
- if huntingdn and open < close // Velas Verdes con Sell Pressure
- sellBox := box.new(left=bar_index, top=high,
- right=bar_index, bottom=(close + high) / 2,
- bgcolor=color.new(#5d606b, 83),
- border_width=1, border_color=color.rgb(222, 11, 11))
- if huntingdn and open > close // Velas Rojas con Sell Pressure
- sellBox := box.new(left=bar_index, top=high,
- right=bar_index, bottom=(open + high) / 2,
- bgcolor=color.new(#5d606b, 83),
- border_width=1, border_color=color.rgb(222, 11, 11))
- // Ajustar la longitud de la caja si no hay nueva señal de Sell Pressure
- else
- box.set_right(id=sellBox, right=bar_index+5)
- // Final del Script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement