How to script "OR" condition for any bullish candlesticks?

c0der

Member
In the scanner, I can pick out the native bullish candlesticks to filter, but I want a "OR" condition, i.e. as long as any bullish pattern turns up (E.g. bullish engulfing / pinbar / mark up bar), then show it in the scan.

How do I code this?
 

mashume

Well-known member
VIP
The best way to do this is to first define a true condition for each of your patterns.
Code:
def engulfing = if high > high[1] and low < low[1] then 1 else 0;
def pinbar = if ... then 1 else 0;
def mark_up_bar = if ... then 1 else 0;
then you can test against all of these conditions at once when you plot your signal:
Code:
plot entry = if engulfing == 1 OR pinbar == 1 OR mark_up_bar == 1 then low else double.nan;
you could alternatively check this way:
Code:
plot entry = if engulfing + pinbar + mark_up_bar >= 1 then low else double.nan;
just for fun.

hope that helps
-mashume
 

Similar threads

Top