Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Scanning for sectors with MAs in order Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
rogertaylor22
Posted : Wednesday, February 24, 2010 4:43:32 PM
Registered User
Joined: 12/9/2009
Posts: 9
Hi - I'm trying to write a PCF to find market sectors where the MAs are in order on the weekly chart.The 20EMA is above the 50SMA which is above the 100SMA. Price doesn't necessarily need to be above the MAs so I don't need to include it as a condition.I've been using XAVGC100 > AVGC250 > AVGC500 but it doesn't work.
Bruce_L
Posted : Wednesday, February 24, 2010 5:22:32 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Welcome to the forums. A very good foundation for learning how to use TeleChart can be gained by reviewing the following:

If you are new to TeleChart READ THIS FIRST!

Please try the following instead:

.0953245136006837 * (C + 19 / 21 * (C5 + 19 / 21 * (C10 + 19 / 21 * (C15 + 19 / 21 * (C20 + 19 / 21 * (C25 + 19 / 21 * (C30 + 19 / 21 * (C35 + 19 / 21 * (C40 + 19 / 21 * (C45 + 19 / 21 * (C50 + 19 / 21 * (C55 + 19 / 21 * (C60 + 19 / 21 * (C65 + 19 / 21 * (C70 + 19 / 21 * (C75 + 19 / 21 * (C80 + 19 / 21 * (C85 + 19 / 21 * (C90 + 19 / 21 * (C95 + 19 / 21 * (C100 + 19 / 21 * (C105 + 19 / 21 * (C110 + 19 / 21 * (C115 + 19 / 21 * (C120 + 19 / 21 * (C125 + 19 / 21 * (C130 + 19 / 21 * (C135 + 19 / 21 * (C140 + 19 / 21 * (C145 + 19 / 21 * (C150 + 19 / 21 * (C155 + 19 / 21 * (C160 + 19 / 21 * (C165 + 19 / 21 * (C170 + 19 / 21 * (C175 + 19 / 21 * (C180 + 19 / 21 * (C185 + 19 / 21 * (C190 + 19 / 21 * (C195 + 19 / 21 * (C200 + 19 / 21 * (C205 + 19 / 21 * (C210 + 19 / 21 * (C215 + 19 / 21 * (C220 + 19 / 21 * (C225 + 19 / 21 * (C230 + 19 / 21 * (C235 + 19 / 21 * (C240 + 19 / 21 * (C245 + 19 / 21 * (C250 + 19 / 21 * (C255 + 19 / 21 * (C260 + 19 / 21 * (C265 + 19 / 21 * (C270 + 19 / 21 * (C275 + 19 / 21 * (C280 + 19 / 21 * (C285 + 19 / 21 * (C290 + 19 / 21 * (C295 + 19 / 21 * (C300 + 19 / 21 * (C305 + 19 / 21 * (C310 + 19 / 21 * (C315 + 19 / 21 * (C320 + 19 / 21 * (C325 + 19 / 21 * (C330 + 19 / 21 * (C335 + 19 / 21 * (C340 + 19 / 21 * (C345)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > (C + C5 + C10 + C15 + C20 + C25 + C30 + C35 + C40 + C45 + C50 + C55 + C60 + C65 + C70 + C75 + C80 + C85 + C90 + C95 + C100 + C105 + C110 + C115 + C120 + C125 + C130 + C135 + C140 + C145 + C150 + C155 + C160 + C165 + C170 + C175 + C180 + C185 + C190 + C195 + C200 + C205 + C210 + C215 + C220 + C225 + C230 + C235 + C240 + C245) / 50 AND C + C5 + C10 + C15 + C20 + C25 + C30 + C35 + C40 + C45 + C50 + C55 + C60 + C65 + C70 + C75 + C80 + C85 + C90 + C95 + C100 + C105 + C110 + C115 + C120 + C125 + C130 + C135 + C140 + C145 + C150 + C155 + C160 + C165 + C170 + C175 + C180 + C185 + C190 + C195 + C200 + C205 + C210 + C215 + C220 + C225 + C230 + C235 + C240 + C245 > C250 + C255 + C260 + C265 + C270 + C275 + C280 + C285 + C290 + C295 + C300 + C305 + C310 + C315 + C320 + C325 + C330 + C335 + C340 + C345 + C350 + C355 + C360 + C365 + C370 + C375 + C380 + C385 + C390 + C395 + C400 + C405 + C410 + C415 + C420 + C425 + C430 + C435 + C440 + C445 + C450 + C455 + C460 + C465 + C470 + C475 + C480 + C485 + C490 + C495

It should probably be noted that your original approximation would need to be broken into two parts to have valid syntax:

XAVGC100 > AVGC250 AND AVGC250 > AVGC500

You may wish to review the following:

How to create a Personal Criteria Forumula (PCF)
PCF Formula Descriptions
Cascades of Moving Averages
Moving Average PCF Templates
Things to check if your moving averages don't "seem right" or "seem to match"

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
rogertaylor22
Posted : Sunday, February 28, 2010 12:00:03 PM
Registered User
Joined: 12/9/2009
Posts: 9
Hi BruceThis is great, many thanks.However why have you gone to the effort of listing out all the closing prices when you can simply use the AVG function? I ask that that from a position of ignorance rather than questioning your vastly superior programming skills!!Also what is .0953245136006837 ?What would you need to do if you wanted it for the daily 20EMA above the 50SMA above the 100SMA?
Bruce_L
Posted : Monday, March 1, 2010 8:48:35 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (rogertaylor22)
This is great, many thanks.However why have you gone to the effort of listing out all the closing prices when you can simply use the AVG function?

You can't just use the Exponential Moving Average function because TeleChart's Personal Criteria Formulas are Daily and you want to get the results for a Weekly Chart. An Exponential Moving Average would be calculated based upon all of the Daily Closes, but the Bars in a Weekly Chart only have a Close once every 5-Trading Days.

QUOTE (rogertaylor22)
Also what is .0953245136006837 ?

The formula is basically 2 / (N + 1) for the most recent term with the weight of all of the older terms being multiplied by (N - 1) / (N + 1) as they get older. If you had an infinite series, this would be enough. Because we are truncating the series, we are increasing the value of all of the terms slightly so the factors all add up to 1. So 2 / 21 = 0.095238095238 (you can just keeping repeating everything after the decimal over and over) gets bumped up to .0953245136006837 (which automatically increases the other terms as well because of the nested parentheses).

QUOTE (rogertaylor22)
What would you need to do if you wanted it for the daily 20EMA above the 50SMA above the 100SMA?

XAVGC20 > AVGC50 AND AVGC50 > AVGC100

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
rogertaylor22
Posted : Wednesday, March 3, 2010 5:44:37 AM
Registered User
Joined: 12/9/2009
Posts: 9
Many Thanks Bruce - really impressed by the support with this product - it really is first class.
Bruce_L
Posted : Wednesday, March 3, 2010 8:20:38 AM


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.