You are on page 1of 1

//@version=3

study("Price Action", overlay=true)

length = input(6, title="Length")


use_volume = input(true, title="Use Volume")
pinbar_tolerance = input(50.0, minval=0, maxval=100, title="Pin Bar Tolerance (%)")
* 0.01
pinbar_wick_ratio = input(30.0, title="Pin Bar Wick Ratio (%)") * 0.01
engulfment_ratio = input(200.0, title="Engulfment Ratio (%)") * 0.01
body = abs(close - open)
wick = high - low
wick_top = high - max(close, open)
wick_bottom = min(close, open) - low

has_volume = use_volume ? volume >= highest(volume, length) : true


is_pinbar = body <= wick * pinbar_tolerance
is_bullish_pinbar = is_pinbar and wick_top < wick_bottom * pinbar_wick_ratio and
low <= lowest(length)
is_bearish_pinbar = is_pinbar and wick_bottom < wick_top * pinbar_wick_ratio and
high >= highest(length)

previous_body = abs(close[1] - open[1])

is_engulfing = body > (previous_body * engulfment_ratio)

is_bullish_engulfing = not is_pinbar and close > open and close[1] < open[1] and
is_engulfing
is_bearish_engulfing = not is_pinbar and close < open and close[1] > open[1] and
is_engulfing

bullish = (is_bullish_pinbar or is_bullish_engulfing) and has_volume


bearish = (is_bearish_pinbar or is_bearish_engulfing) and has_volume

plotshape(bullish, title="Bullish", style=shape.circle, location=location.belowbar,


color=lime)
plotshape(bearish, title="Bearish", style=shape.circle, location=location.abovebar,
color=red)

You might also like