Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 8/26/2006 Posts: 20
|
trainers,
I would like a PCF to return the difference between the last two weekly values of a 13 week EMA
ie. if this weeks was higher than last weeks it would be positve, negative if lower.
I would also be grateful if you would explain how it works.
I have found the PCF's for weekly EMA's on this forum but because I don't understand how it works I can't convert it to 13 week EMA.
this is in relation to my previous post about using data bars to indicate Elder impulse system
thanks in advance
Adrian
|
|
Worden Trainer
Joined: 10/1/2004 Posts: 18,819
|
What value should the PCF return? +1, 0 or -1?
- Craig Here to Help!
|
|
Registered User Joined: 8/26/2006 Posts: 20
|
Craig,
thank you for replying.
the PCF should just return the difference between the two values.
it would be positive if this weeks 13 bar ema was higher than last weeks and positve if vice versa
thanks
Adrian
|
|
Worden Trainer
Joined: 10/1/2004 Posts: 18,819
|
To confirm: you want a PCF that gives the 1-bar net difference of a 13-bar ema of price on a 5-day chart?
If so, this should work:
0.142996048056393 * (C0 + 12 / 14 * (C5 + 12 / 14 * (C10 + 12 / 14 * (C15 + 12 / 14 * (C20 + 12 / 14 * (C25 + 12 / 14 * (C30 + 12 / 14 * (C35 + 12 / 14 * (C40 + 12 / 14 * (C45 + 12 / 14 * (C50 + 12 / 14 * (C55 + 12 / 14 * (C60 + 12 / 14 * (C65 + 12 / 14 * (C70 + 12 / 14 * (C75 + 12 / 14 * (C80 + 12 / 14 * (C85 + 12 / 14 * (C90 + 12 / 14 * (C95 + 12 / 14 * (C100 + 12 / 14 * (C105 + 12 / 14 * (C110 + 12 / 14 * (C115 + 12 / 14 * (C120 + 12 / 14 * (C125 + 12 / 14 * (C130 + 12 / 14 * (C135 + 12 / 14 * (C140 + 12 / 14 * (C145 + 12 / 14 * (C150 + 12 / 14 * (C155 + 12 / 14 * (C160 + 12 / 14 * (C165 + 12 / 14 * (C170 + 12 / 14 * (C175 + 12 / 14 * (C180 + 12 / 14 * (C185 + 12 / 14 * (C190 + 12 / 14 * (C195 + 12 / 14 * (C200 + 12 / 14 * (C205 + 12 / 14 * (C210 + 12 / 14 * (C215)))))))))))))))))))))))))))))))))))))))))))) - 0.142996048056393 * (C5 + 12 / 14 * (C10 + 12 / 14 * (C15 + 12 / 14 * (C20 + 12 / 14 * (C25 + 12 / 14 * (C30 + 12 / 14 * (C35 + 12 / 14 * (C40 + 12 / 14 * (C45 + 12 / 14 * (C50 + 12 / 14 * (C55 + 12 / 14 * (C60 + 12 / 14 * (C65 + 12 / 14 * (C70 + 12 / 14 * (C75 + 12 / 14 * (C80 + 12 / 14 * (C85 + 12 / 14 * (C90 + 12 / 14 * (C95 + 12 / 14 * (C100 + 12 / 14 * (C105 + 12 / 14 * (C110 + 12 / 14 * (C115 + 12 / 14 * (C120 + 12 / 14 * (C125 + 12 / 14 * (C130 + 12 / 14 * (C135 + 12 / 14 * (C140 + 12 / 14 * (C145 + 12 / 14 * (C150 + 12 / 14 * (C155 + 12 / 14 * (C160 + 12 / 14 * (C165 + 12 / 14 * (C170 + 12 / 14 * (C175 + 12 / 14 * (C180 + 12 / 14 * (C185 + 12 / 14 * (C190 + 12 / 14 * (C195 + 12 / 14 * (C200 + 12 / 14 * (C205 + 12 / 14 * (C210 + 12 / 14 * (C215 + 12 / 14 * (C220))))))))))))))))))))))))))))))))))))))))))))
- Craig Here to Help!
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Let's start with the final formula:
(C - .142996048056393 * (C5 + 6 / 7 * (C10 + 6 / 7 * (C15 + 6 / 7 * (C20 + 6 / 7 * (C25 + 6 / 7 * (C30 + 6 / 7 * (C35 + 6 / 7 * (C40 + 6 / 7 * (C45 + 6 / 7 * (C50 + 6 / 7 * (C55 + 6 / 7 * (C60 + 6 / 7 * (C65 + 6 / 7 * (C70 + 6 / 7 * (C75 + 6 / 7 * (C80 + 6 / 7 * (C85 + 6 / 7 * (C90 + 6 / 7 * (C95 + 6 / 7 * (C100 + 6 / 7 * (C105 + 6 / 7 * (C110 + 6 / 7 * (C115 + 6 / 7 * (C120 + 6 / 7 * (C125 + 6 / 7 * (C130 + 6 / 7 * (C135 + 6 / 7 * (C140 + 6 / 7 * (C145 + 6 / 7 * (C150 + 6 / 7 * (C155 + 6 / 7 * (C160 + 6 / 7 * (C165 + 6 / 7 * (C170 + 6 / 7 * (C175 + 6 / 7 * (C180 + 6 / 7 * (C185 + 6 / 7 * (C190 + 6 / 7 * (C195 + 6 / 7 * (C200 + 6 / 7 * (C205 + 6 / 7 * (C210 + 6 / 7 * (C215 + 6 / 7 * (C220 + 6 / 7 * (C225)))))))))))))))))))))))))))))))))))))))))))))) / 7
Now how did we get there?
XAVGCp - XAVGCp.1 = 2 * (C - XAVGCp.1) / (p + 1)
Where p = the EMA Period.
The weekly XAVGCp.1 needs to be expanded because it is not one day per bar. One way to expand XAVGCp is:
XAVGCp = 2 / (p + 1) * (C + (p - 1) / (p + 1) * (C1 + (p - 1) / (p + 1) * (C2 + (p - 1) / (p + 1) * (C3 + (p - 1) / (p + 1) * (C4 + (p - 1) / (p + 1) * (C5 + ... (p - 1) / (p + 1) * (Cx) ...))))))
The more terms (nested parentheses), the more accurate the result. Doing this for a weekly version of XAVGC13.1 results in:
2 / (13 + 1) * (C5 + (13 - 1) / (13 + 1) * (C10 + (13 - 1) / (13 + 1) * (C15 + (13 - 1) / (13 + 1) * (C20 + (13 - 1) / (13 + 1) * (C25 + (13 - 1) / (13 + 1) * (C30 + (13 - 1) / (13 + 1) * (C35 + (13 - 1) / (13 + 1) * (C40 + (13 - 1) / (13 + 1) * (C45 + (13 - 1) / (13 + 1) * (C50 + (13 - 1) / (13 + 1) * (C55 + (13 - 1) / (13 + 1) * (C60 + (13 - 1) / (13 + 1) * (C65 + (13 - 1) / (13 + 1) * (C70 + (13 - 1) / (13 + 1) * (C75 + (13 - 1) / (13 + 1) * (C80 + (13 - 1) / (13 + 1) * (C85 + (13 - 1) / (13 + 1) * (C90 + (13 - 1) / (13 + 1) * (C95 + (13 - 1) / (13 + 1) * (C100 + (13 - 1) / (13 + 1) * (C105 + (13 - 1) / (13 + 1) * (C110 + (13 - 1) / (13 + 1) * (C115 + (13 - 1) / (13 + 1) * (C120 + (13 - 1) / (13 + 1) * (C125 + (13 - 1) / (13 + 1) * (C130 + (13 - 1) / (13 + 1) * (C135 + (13 - 1) / (13 + 1) * (C140 + (13 - 1) / (13 + 1) * (C145 + (13 - 1) / (13 + 1) * (C150 + (13 - 1) / (13 + 1) * (C155 + (13 - 1) / (13 + 1) * (C160 + (13 - 1) / (13 + 1) * (C165 + (13 - 1) / (13 + 1) * (C170 + (13 - 1) / (13 + 1) * (C175 + (13 - 1) / (13 + 1) * (C180 + (13 - 1) / (13 + 1) * (C185 + (13 - 1) / (13 + 1) * (C190 + (13 - 1) / (13 + 1) * (C195 + (13 - 1) / (13 + 1) * (C200 + (13 - 1) / (13 + 1) * (C205 + (13 - 1) / (13 + 1) * (C210 + (13 - 1) / (13 + 1) * (C215 + (13 - 1) / (13 + 1) * (C220 + (13 - 1) / (13 + 1) * (C225)))))))))))))))))))))))))))))))))))))))))))))
Which can be substituted into our 2 * (C - XAVGCp.1) / (p + 1) formula as follows:
2 * (C - 2 / (13 + 1) * (C5 + (13 - 1) / (13 + 1) * (C10 + (13 - 1) / (13 + 1) * (C15 + (13 - 1) / (13 + 1) * (C20 + (13 - 1) / (13 + 1) * (C25 + (13 - 1) / (13 + 1) * (C30 + (13 - 1) / (13 + 1) * (C35 + (13 - 1) / (13 + 1) * (C40 + (13 - 1) / (13 + 1) * (C45 + (13 - 1) / (13 + 1) * (C50 + (13 - 1) / (13 + 1) * (C55 + (13 - 1) / (13 + 1) * (C60 + (13 - 1) / (13 + 1) * (C65 + (13 - 1) / (13 + 1) * (C70 + (13 - 1) / (13 + 1) * (C75 + (13 - 1) / (13 + 1) * (C80 + (13 - 1) / (13 + 1) * (C85 + (13 - 1) / (13 + 1) * (C90 + (13 - 1) / (13 + 1) * (C95 + (13 - 1) / (13 + 1) * (C100 + (13 - 1) / (13 + 1) * (C105 + (13 - 1) / (13 + 1) * (C110 + (13 - 1) / (13 + 1) * (C115 + (13 - 1) / (13 + 1) * (C120 + (13 - 1) / (13 + 1) * (C125 + (13 - 1) / (13 + 1) * (C130 + (13 - 1) / (13 + 1) * (C135 + (13 - 1) / (13 + 1) * (C140 + (13 - 1) / (13 + 1) * (C145 + (13 - 1) / (13 + 1) * (C150 + (13 - 1) / (13 + 1) * (C155 + (13 - 1) / (13 + 1) * (C160 + (13 - 1) / (13 + 1) * (C165 + (13 - 1) / (13 + 1) * (C170 + (13 - 1) / (13 + 1) * (C175 + (13 - 1) / (13 + 1) * (C180 + (13 - 1) / (13 + 1) * (C185 + (13 - 1) / (13 + 1) * (C190 + (13 - 1) / (13 + 1) * (C195 + (13 - 1) / (13 + 1) * (C200 + (13 - 1) / (13 + 1) * (C205 + (13 - 1) / (13 + 1) * (C210 + (13 - 1) / (13 + 1) * (C215 + (13 - 1) / (13 + 1) * (C220 + (13 - 1) / (13 + 1) * (C225)))))))))))))))))))))))))))))))))))))))))))))) / (13 + 1)
We just need to simplify and adjust the 2 / (13 + 1) in the expanded EMA calculation to .142996048056393 to achieve unity (meaning the factors used for each term add up to one) to get the formula presented at the start of this post.
You may wish to review the following:
Cascades of Moving Averages
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 8/26/2006 Posts: 20
|
thank you both.
especially for taking the time to explain the the formula
I think I'm definately getting value for money with the quality of your support.
now, I'm sure i read in one of Bruce_L posts that PCF is the easiest script language in the business!
I'm glad I don't have to learn anything hard
thanks
Adrian
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome. Our pleasure. I hope that's not a direct quote. I would actually call TeleChart's PCF Language a formula language, not a scripting language.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Worden Trainer
Joined: 10/1/2004 Posts: 18,819
|
In my opinion, the easiest language is Blocks and Block Diagrams in SnapSheets. It has none of the restrictions the PCF language.
- Craig Here to Help!
|
|
Guest-1 |