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 |

Price % above/below a given moving average Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Fisher2
Posted : Monday, January 13, 2014 9:29:45 AM
Gold Customer Gold Customer

Joined: 8/13/2009
Posts: 73

Bruce,

Can a PCF be written for a condition or indicator where the percentage a price is above or below a given moving average?  If so, would be so kind as to write one for price percentage above and below a 40 day simple moving average.

Julian

Bruce_L
Posted : Monday, January 13, 2014 11:05:29 AM


Worden Trainer

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

The following Indicator Formula returns the percentage that price is above or below its own 40-period simple moving average:

100 * (C / AVGC40 - 1)

You can change the AVGC40 part of the Indicator Formula to adjust the moving average being used.

PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Fisher2
Posted : Monday, January 13, 2014 11:12:40 AM
Gold Customer Gold Customer

Joined: 8/13/2009
Posts: 73

Thanks, Bruce, I just never seem to get these things right.  Appreciate it.

sonel
Posted : Tuesday, January 14, 2014 2:12:09 PM
Registered User
Joined: 7/2/2013
Posts: 4

Bruce, could you please help me with a formula that scan all the stocks below 10 dollars price that are between .5% and 7 % above 13 exponential ma in a daily basis

Bruce_L
Posted : Tuesday, January 14, 2014 2:18:20 PM


Worden Trainer

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

Please try the following Condition Formula:

C < 10 AND 1.005 * XAVGC13 <= C AND C <= 1.07 * XAVGC13



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
TBradley
Posted : Sunday, May 24, 2015 10:20:25 AM
Gold Customer Gold Customer

Joined: 1/22/2005
Posts: 73

In continuation of my never ending search, can this be coded into TC2007? 

"DAMA" is "days above moving average", and "PAMA" is "percent above moving average"

Bruce_L
Posted : Tuesday, May 26, 2015 11:17:53 AM


Worden Trainer

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

The Friday, April 24, 2015 3:05:49 PM ET post in the Is it possible to write a pcf that will output bars up? topic is an example of counting the number of bars above a moving average.

The percent above or below a 20-period simple moving average can be done as follows.

100 * (C / AVGC20 - 1)

You could change the AVGC20 to something else to use a different period or type of moving average.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bluerhino
Posted : Tuesday, May 26, 2015 11:13:49 PM
Registered User
Joined: 3/22/2005
Posts: 11

How do I create a PCF to scan for a 20 day SMA crossing up across a 20/20 Bollinger Band either 5 days ago or 4 days ago?

Thanks a lot.

BR

Bruce_L
Posted : Wednesday, May 27, 2015 9:04:42 AM


Worden Trainer

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

I'm not sure I understand. Is the Bollinger Band of the moving average?

Through which line of the Bollinger Bands must the moving average have crossed?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bluerhino
Posted : Friday, May 29, 2015 4:29:00 PM
Registered User
Joined: 3/22/2005
Posts: 11

Bruce, it's the SMA of price crossing up above the lower BB.

Similarly, what would the formula for the 20 SMA crossing down across the upper BB look like.

Sorry for the lack of clarity.

Thanks.

BR

 

 

 

 

Bruce_L
Posted : Friday, May 29, 2015 4:40:27 PM


Worden Trainer

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

OK, I must be misunderstanding something then.

The central line of a Bollinger Band 20, 2.00 is usually a a 20 period simple moving average. This means it can't cross through either Bollinger Band because those lines add and subtract a multiple of the standard deviation from the central line.

Are you sure the moving average and Bollinger Bands both have the same periods and are both of price?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bluerhino
Posted : Friday, June 5, 2015 1:54:03 PM
Registered User
Joined: 3/22/2005
Posts: 11

Bruce, you're absolutely right of course. I use the default numbers, the Bollinger Band 20, 2.00 with the 20 being a simple moving average. The moving average of price should be either 50 or 200, not 20 as I mistakenly wrote earlier.

Your correction reminds me that I use the 50 and 200 period simple moving averages. So  if possible I would like to scan for either the 50 or 200 daily moving average crossing from below to above the lower Bollinger band OR the 50 or 200 daily moving average crossing from above to below the upper Bollinger Band.

I assume that the daily formula will translate seamlessly to the 30 minute and weekly timeframes.

Thanks for your patience.

BR

 

 

 

Bruce_L
Posted : Friday, June 5, 2015 3:26:22 PM


Worden Trainer

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

A Condition Formula for either the 50 or 200 period simple moving average crossing up through the simple lower Bollinger Band 20, 2.00 can be written as follows.

(AVGC50 > AVGC20 - 2 * 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) / 20) AND AVGC50.1 <= AVGC20.1 - 2 * SQR(ABS(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 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 20)) OR (AVGC200 > AVGC20 - 2 * 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) / 20) AND AVGC200.1 <= AVGC20.1 - 2 * SQR(ABS(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 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 20))

A Condition Formula for either the 50 or 200 period simple moving average crossing down through the simple upper Bollinger Band 20, 2.00 can be written as follows.

(AVGC50 < AVGC20 + 2 * 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) / 20) AND AVGC50.1 >= AVGC20.1 + 2 * SQR(ABS(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 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 20)) OR (AVGC200 < AVGC20 + 2 * 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) / 20) AND AVGC200.1 >= AVGC20.1 + 2 * SQR(ABS(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 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 20))

Modelling Bollinger Bands (& Standard Deviation) in a TC PCF



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bluerhino
Posted : Monday, June 8, 2015 3:43:14 PM
Registered User
Joined: 3/22/2005
Posts: 11

Thanks a lot Bruce.
 

BR

Bruce_L
Posted : Monday, June 8, 2015 3:50:35 PM


Worden Trainer

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

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.