Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

bollinger Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
mktwizard123
Posted : Thursday, August 27, 2009 9:21:20 AM
Registered User
Joined: 5/17/2006
Posts: 493
hi, if my bollinger settings are period = 5, width = 30, how do I write a pcf that shows if price is touching or is above or below the bands for that day.
thanks
Bruce_L
Posted : Thursday, August 27, 2009 9:47:12 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
One way to write a formula for the Upper Bollinger Band 5,30 is:

AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

One way to write a formula for the Lower Bollinger Band 5,30 is:

AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

The formulas for Price touching or being above or below the Bollinger Bands depends on what portion of Price you mean and which Bollinger Band or Bands are being checked:

Close at or above Upper Bollinger Band:

C >= AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close above Upper Bollinger Band:

C > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close at or below Upper Bollinger Band:

C <= AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close below Upper Bollinger Band:

C < AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close at or above Lower Bollinger Band:

C >= AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close above Lower Bollinger Band:

C > AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close at or below Lower Bollinger Band:

C <= AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close below Lower Bollinger Band:

C < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close outside Bollinger Bands:

ABS(C - AVGC5) > 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Close inside Bollinger Bands:

ABS(C - AVGC5) < 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar at or above Upper Bollinger Band:

H >= AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar above Upper Bollinger Band:

H > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar at or below Upper Bollinger Band:

L <= AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar below Upper Bollinger Band:

L < AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar at or above Lower Bollinger Band:

H >= AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar above Lower Bollinger Band:

H > AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar at or below Lower Bollinger Band:

L <= AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar below Lower Bollinger Band:

L < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar outside Bollinger Bands:

H > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4) OR L < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar inside Bollinger Bands:

H > AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4) OR L < AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar above Upper Bollinger Band:

L > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar below Upper Bollinger Band:

H < AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar above Lower Bollinger Band:

L > AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar below Lower Bollinger Band:

H < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar outside Bollinger Bands:

L > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4) OR H < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar inside Bollinger Bands:

L > AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4) AND H < AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

You may wish to review the following:

Modelling Bollinger Bands (& Standard Deviation) in a TC PCF
PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!
How to create a Personal Criteria Forumula (PCF)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mktwizard123
Posted : Thursday, August 27, 2009 10:10:59 AM
Registered User
Joined: 5/17/2006
Posts: 493
wow, thanks bruce, if i wanted to write these for stockfinder, can you help with that? I would only like the following.

At least part of Bar at or above Upper Bollinger Band:

H >= AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar above Upper Bollinger Band:

H > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar at or below Upper Bollinger Band:

L <= AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar below Upper Bollinger Band:

L < AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar at or above Lower Bollinger Band:

H >= AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar above Lower Bollinger Band:

H > AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar at or below Lower Bollinger Band:

L <= AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar below Lower Bollinger Band:

L < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

At least part of Bar outside Bollinger Bands:

H > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4) OR L < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar above Upper Bollinger Band:

L > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar below Upper Bollinger Band:

H < AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar above Lower Bollinger Band:

L > AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar below Lower Bollinger Band:

H < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

Entire Bar outside Bollinger Bands:

L > AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4) OR H < AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)


Bruce_L
Posted : Thursday, August 27, 2009 10:29:45 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
To do the same thing in StockFinder, add a 1-Period Simple Moving Average of OHLC Indicator to Price History to extract the High or Low. Then Drag and Drop the Moving Average of OHLC Indicator onto the Bollinger Bands and select Create Rule | Above (or Below) | Bollinger Bands Top (or Bottom) to duplicate the comparisons. If there is more than one comparison, Drag and Drop the component Rules onto each other and select Create New Combo Rule and then adjust it to And or Or to match the Personal Criteria Formula.

If this doesn't seem to make sense, please review the Rule Basics video.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mktwizard123
Posted : Thursday, August 27, 2009 11:28:25 AM
Registered User
Joined: 5/17/2006
Posts: 493
bruce, i'm new to stockfinder so bare with me, i've reviewd all the videos, so lets say I want to just use this specific pcf (from above) in stockfinderand scan real time for this condition on a daily chart. - meaning that this condition alerts me when its touching the band using the bollingers on a daily chart.

L <= AVGC5 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

would i still follow your suggestion?
Bruce_L
Posted : Thursday, August 27, 2009 11:47:54 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Yes.

You would add Bollinger Bands to Price History and adjust the settings to Period: 5, Average Type: Simple and Std Dev: 3.

Then add a Moving Average of OHLC Indicator to Price History and change the settings to Average Type: Simple, MovAvg Period: 1, Average of: Bar Low and Offset: 0.

Then Drag and Drop the Moving Average onto the Bollinger Bands and select Below Bollinger Bands, Period 5, Std Dev 3 - Bottom.

If you want to use the Rule as a Scan, Drag and Drop it to the Watchlist and select Scan.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mktwizard123
Posted : Monday, August 31, 2009 10:20:44 PM
Registered User
Joined: 5/17/2006
Posts: 493
thx bruce, one last question, if I want this pcf as above..

H >= AVGC5 + 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 - 5 * AVGC5 ^ 2) / 4)

do I do everything exactly as above but

Average of: Bar Low and Offset: 0. to 

average of bar high?

and 

select Below Bollinger Bands, Period 5, Std Dev 3 - Bottom.

to

 select above Bollinger Bands, Period 5, Std Dev 3 - top.
Bruce_L
Posted : Tuesday, September 1, 2009 7:48:12 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Your suggested alterations would appear to be correct to me.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
dunsek
Posted : Friday, November 13, 2009 8:56:28 AM
Registered User
Joined: 3/20/2009
Posts: 11
Hi Bruce- need your help once more please on the lower 3rd std deviation bollinger band. I'm using this formula:AVGC20 - 3 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 19)to create a lower bollinger band that I can then compare price to on the chart and sort by the % difference the stocks in my watch list are away from that lower band. I had it working and managed to exit without saving the template, and am having a heck of a time recreating it. The formula above drapes a new indicator below, and in some spots significantly below the 20,30 lower bollinger band. Do you see anything immediately wrong with that formula to explain why it doesn't track the system generated bb?
Bruce_L
Posted : Friday, November 13, 2009 9:01:22 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
dunsek,
Make sure that Plot using price scale is checked for the Custom Indicator and that you are using Arithmetic Scaling on your Chart.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
dunsek
Posted : Friday, November 13, 2009 9:05:03 AM
Registered User
Joined: 3/20/2009
Posts: 11
Hi Bruce- checking the center zero line and using arithmetic throws it off even more. Now instead of being just below the system generated bollinger band, that indicator is just under the upper band!
Bruce_L
Posted : Friday, November 13, 2009 9:07:09 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
dunsek,
Please try checking Plot using price scale instead of Center Zero Line.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
dunsek
Posted : Friday, November 13, 2009 9:07:18 AM
Registered User
Joined: 3/20/2009
Posts: 11
Hi Bruce-- never mind! It's working properly with arithmetic, as long as I don't check the center zero line option.Many thanksKD
Bruce_L
Posted : Friday, November 13, 2009 9:07:53 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
dunsek,
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.