Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
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
|
|
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
|
|
Gold Customer
Joined: 8/13/2009 Posts: 73
|
Thanks, Bruce, I just never seem to get these things right. Appreciate it.
|
|
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
|
|
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
|
|
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"
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
Registered User Joined: 3/22/2005 Posts: 11
|
Thanks a lot Bruce.
BR
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |