Hi, Would anyone be able to help with the coding on how to screen for 2 consecutive pinbars? I have had a look on the forum and can only see coding for one pinbar and struggling to know how to code for 2 pinbars.
Thanks
If anyone can provide any wisdom to this you would make my day! 🙂 I’ve scanned all 20 pages in this forum as well as reading the 29 page manual on coding with the hope of finding a few snippets of code to help in my quest and I’m still none the wiser.
How do you want a Pin Bar to be defined?
- number of pips of upper shadow (or percentage on whole range), i.e. say 20 pips or 50%-70% of its range
- number of pips of lower shadow (or percentage on whole range), i.e. say 5 pips or 5%-30% of its range
- number of pips of body size (or percentage on whole range), i.e. say 10 pips or 5%-20% of its range.
Once it’s defined it will be easy to detect as many as you want.
I found an old topic with a Pinbar code, made a consecutive 2 bullish or bearish pinbars detection screener:
body = ABS(open-close)
bearishwick = ABS(high-close)
bearishnose = ABS(close-low)
bullishwick = ABS(close-low)
bullishnose = ABS(high-close)
//bearish pinbar
bearishpinbar = (body/bearishwick)<20/100 AND (body/bearishnose)>100/100
//bullish pinbar
bullishpinbar = (body/bullishwick)<20/100 and (body/bullishnose)>100/100
test = summation[2](bearishpinbar or bullishpinbar)=2
screener [test]
In each case, the body of candlestick must be inferior to 20% of the wick, and larger than nose.
Thanks Nicolas, much appreciated, is there a way of getting the two previous bars before the current one? Just that if I run this for Daily Pinbars, it would include a forming Pinbar which might not end up being a pinbar once the candle closes.
Cheers
You can try by modifying the line 13:
test = summation[3](bearishpinbar or bullishpinbar)>=2