BBand Script

What is the best way to script to find if the close if within x% of the upper and lower bolly bands?

Thanks,
Dan

Hi Dan,

You can use the WITHINRANGE() function. Here’s an example for 1% on the 20 day BB:

LL1 = BB(BARS=20).LowerLine;
UL1 = BB(BARS=20).UpperLine;

WITHINRANGE(CLOSE(), LL1, PERCENT=1.00) or 
WITHINRANGE(CLOSE(), UL1, PERCENT=1.00)

Attached is a workbook that you can download and open which has the areas shaded red for within 1% of the upper line, and green for lower line.

BBPct.owb (13.5 KB)