quantized pin bar indicator with ATR

This script computes the strength of pin bars.
This script uses the corrent and the previous two bars to compute the strength of pin bars.
The strength of pin bars can be also comared with average true range , so we can evaluate those pin bars are strong or weak.

Pin bar is a popular price action trading strategy.
It is based on quick price rejection.
Most of existing pin bar scripts only determine if a bar is a pin bar or not.
However, evaluating the strength of pin bars is important.
If price rejection is too weak, it is difficult to trigger trend reversal.
If a pin bar is too strong, we may enter the trade too late and cannot have good profit.
In this script, it provides a method to compute to strength of pin bars.
After the strength of pin bars are quantized, they can compare with average true range , price range and trend strength, which can help us to determine where are worthy for us to open trades.

Bullish hammer : current low is lower than ( previous high or current open ) and current close.
Bearish gravestone : current high is higher than ( previous low or current open ) and current close.
Bullish engulfing and harami : ( current low or previous low ) is lower than ( previous 2nd high or previous open ) and current close.
Bearish engulfing and harami : ( current high or previous high ) is higher than ( previous 2nd low or previous open ) and current close.

Smoothing : the type of computing average.
Length of ATR : determines the number of true ranges for computing average true range .
ATR multiplier line : the threshould that a pin bar is strong enough. For example, if this value is 0.5, it means a pin bar with 0.5*atr or more is considered a strong pin bar .
one direction pinbar : set to 1 if you want the strength of bullish pin bars and bearish pin bars are cancelled. Set to 0 if you want to keep both strength of bullish pin bars and bearish pin bars; in this case, you may need to change the plot style to make both strength visible.

Trading Suggestions
Evaluate the strength of trend against pin bars. After all, a single reverse pin bar may be too weak to reverse the trend.
Timeframe : if atr is higher than 4*spread, the timeframe is high enough. However, if strong pin bars appear too frequent or price range is too small, going to higher fimeframe may be more safe.
Entry and exit : according to personal flavors.

The strength of pin bars can be quantized.
With this indicator, we can find more potential pin bars which human eyes and binary pattern detectors were leaked.
In my opinion, 0.5*atr is the most suitable streng of a pin bar for my trade entry but I still need to consider the direction of the trend.
You are welcome to share your settings and related trading strategy.

Most of related knowledge can be searched from the internet.
I cannot say the exact references because they may violate the rules of Tradingview.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Home Stock Screener Forex Screener Crypto Screener Economic Calendar About Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter