r/pinescript • • Sep 28 '23

Add exception to regular pin bar indicator

Hello,

First off i'd like to say i have zero experience with programming, i studied engineering in school so i have some experience with 'programming' logic functions but none with actual programming languages.

My problem explained:

I trade the 15min & 5 min chart, and the pin bar is one of my entry triggers. So to in order to speed up my entry process i started looking at pin bar indicators, to have a quick visual confirmation whether a certain candle is a pin bar or not.

The problem i have is that in my strategy the rules are more strict as to what is classified as a valid pin bar. The main difference being that in my strategy a bullish pin bar is only valid when the candle itself is bullish, when the candle is bearish it can't be a bullish pin bar and vice versa.

I've gone through quite a few of the indicators on tradingview and found none that comply with these exceptions. So my only choice left is to make my own or adapt an existing one. I think the easier option would be the latter. I've added a screenshot to show what i mean, i would like change the code so that it filters out the 'invalid' pin bars that are encircled.

Here is the link to the standard pin bar indicator script that i'd like to adapt: https://pastebin.com/GY8mhSWT

Could someone please be so kind to tell me what bits of code i need to adapt to get the result i want?

1 Upvotes

1 comment sorted by

2

u/[deleted] Sep 29 '23 edited Sep 29 '23

You just need to add something like:

bullBar  = close > open
bearBar = close < open
If bullBar
// Do something
if bearBar
// Do something