| Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 12/30/2005 Posts: 6
|
I want to setup "Polarized Fractal Efficiency" as an indicator on the chart screen. Here's the MetaStock language formula for the five period smoothed 10-day (what I want).
Mov(If(C,>,Ref(C,-9),Sqr(Pwr(Roc(C,9,$),2) + Pwr(10,2)) / Sum(Sqr(Pwr(Roc(C,1,$),2)+1),9),- Sqr(Pwr(Roc(C,9,$),2) + Pwr(10,2)) / Sum(Sqr(Pwr(Roc(C,1,$),2)+1),9))*100,5,E)
Didn't see it come up in past discussion.
Appreciate the help,
casey
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please try the following:
Select Chart Template | Add Indicator | Indicator. - Visible: Checked - Center Zero Line: Checked - Plot using price scale: Unchecked - Smoothing Average: 5 - Average Type: Exponential - Indicator Formula: 100 * SQR((C - C9) ^ 2 + 100) / (SQR((C - C1) ^ 2 + 1) + SQR((C1 - C2) ^ 2 + 1) + SQR((C2 - C3) ^ 2 + 1) + SQR((C3 - C4) ^ 2 + 1) + SQR((C4 - C5) ^ 2 + 1) + SQR((C5 - C6) ^ 2 + 1) + SQR((C6 - C7) ^ 2 + 1) + SQR((C7 - C8) ^ 2 + 1) + SQR((C8 - C9) ^ 2) + 1) * SGN(C - C9)
You may wish to review the following:
Plotting Custom Indicators with Examples Handy PCF example formulas to help you learn the syntax of PCFs!
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/1/2005 Posts: 2,645
|
Bruce,
You replaced SQR((C-C1)^2+1) by ABS(C-C1)+1 in the denominator.
If you agree and correct the PCF, please delete this post.
Thanks, Jim Murphy
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
bustermu, I agreed and corrected the post, but, that said, I think the supplied MetaStock language formula is incorrect. I don't have a copy of the article, but my understanding is that the indicator is supposed to run from -100 to 100. I would think one of the following is probably closer:
Select Chart Template | Add Indicator | Indicator. - Visible: Checked - Center Zero Line: Checked - Plot using price scale: Unchecked - Smoothing Average: 5 - Average Type: Exponential - Indicator Formula: 100 * SQR((C - C10) ^ 2 + 100) / (SQR((C - C1) ^ 2 + 1) + SQR((C1 - C2) ^ 2 + 1) + SQR((C2 - C3) ^ 2 + 1) + SQR((C3 - C4) ^ 2 + 1) + SQR((C4 - C5) ^ 2 + 1) + SQR((C5 - C6) ^ 2 + 1) + SQR((C6 - C7) ^ 2 + 1) + SQR((C7 - C8) ^ 2 + 1) + SQR((C8 - C9) ^ 2 + 1) + SQR((C9 - C10) ^ 2 + 1)) * SGN(C - C10)
Select Chart Template | Add Indicator | Indicator. - Visible: Checked - Center Zero Line: Checked - Plot using price scale: Unchecked - Smoothing Average: 5 - Average Type: Exponential - Indicator Formula: 100 * SQR((C - C9) ^ 2 + 81) / (SQR((C - C1) ^ 2 + 1) + SQR((C1 - C2) ^ 2 + 1) + SQR((C2 - C3) ^ 2 + 1) + SQR((C3 - C4) ^ 2 + 1) + SQR((C4 - C5) ^ 2 + 1) + SQR((C5 - C6) ^ 2 + 1) + SQR((C6 - C7) ^ 2 + 1) + SQR((C7 - C8) ^ 2 + 1) + SQR((C8 - C9) ^ 2 + 1)) * SGN(C - C9)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/1/2005 Posts: 2,645
|
Bruce,
I have not yet found a correct formula for Polarized Fractal Efficiency.
The fact that the two PCFs you gave range from -100 to +100 follows from the inequality:
(EX)^2+1 <= (E(SQR(X^2+1)))^2
for Expection ( E ) and random variable ( X ).
Apparently you were aware of this inequality. I don't recall ever having seen it before proving it today.
Thanks, Jim Murphy
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
QUOTE ( Stocks & Commodities V. 12:1 (38-41): Polarized Fractal Efficiency by Hans Hannula, Ph.D., C.T.A.) Here are the resulting mathematical equation for computing Pfe. Each close-to-close line is treated as the hypotenuse of a triangle, the length of which is computed as the square root of the squares of the sides. Adding the close-to-close lengths together gives the length of distance A. Distance B is simply the hypotenuse of the triangle between the first and last close. So the basis of the formulas is finding the hypotenuse of a triangle where time forms one leg and the net change in price forms the other. It's pretty much just the ratio of the hypotenuse of the large triangle created by doing this for the entire period to the sums of the hypotenuses of the smaller triangles generated for each bar. The result is expressed as a percentage and adjusted for the sign of the net change over the entire period.
Based on this, it would seem that one of the second two formulas given is correct. I cannot determine which one however as both the formula given and the example spreadsheet seem to mismatch the period in the same way as the provided MetaStock code (so maybe the first formula is actually right since it matches both the formula given and the example spreadsheet in the article?).
Another wrinkle from the article is that this is actually done based on straight lines on Logarithmic charts, but I'm not sure I see this as being particularly important for a 10-Period version on Daily charts.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/1/2005 Posts: 2,645
|
Bruce,
Thanks for the information. So, the shortest distance (in a plane) between two points (in the plane) is a straight line? Who would have thought that?
Would you say my fancy "new" Probability Theory inequality is an overkill? Nevertheless, I am greatful to you for helping me learn something today.
Thanks, Jim Murphy
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
bustermu, Don't feel bad. I hadn't thought of it in terms of triangles and straight lines before getting a chance to read the article either. I just found the results a bit puzzling after the descriptions I read while searching on the internet and decided to "fix" it.
You didn't supply the actual steps in your proof, so I can't say how much overkill was involved on your end. I can say for certain that had I read the article first or figured out on my own to think of it in terms of the shortest distance between two points being a straight line, I would have been able to "fix" the formula more quickly.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/1/2005 Posts: 2,645
|
QUOTE (Bruce_L) Another wrinkle from the article is that this is actually done based on straight lines on Logarithmic charts, but I'm not sure I see this as being particularly important for a 10-Period version on Daily charts.
Bruce,
The PCFs you gave return very different results if each Ck is replaced by LOG(Ck). The result becomes invariant under a scale change, but, unfortunately, it is not invariant under a change in the base of the logarithm. There appears to me to be something wrong with the whole concept. One may just as well filter SGN(C-C10).
Being without access to the literature at present, I would suggest replacing the PCF by:
100 * LOG(C / C10) / (ABS(LOG(C / C1)) + ABS(LOG(C1 / C2)) + ABS(LOG(C2 / C3)) + ABS(LOG(C3 / C4)) + ABS(LOG(C4 / C5)) + ABS(LOG(C5 / C6)) + ABS(LOG(C6 / C7)) + ABS(LOG(C7 / C8)) + ABS(LOG(C8 / C9)) + ABS(LOG(C9 / C10)))
Thanks, Jim Murphy
|
|
Registered User Joined: 12/30/2005 Posts: 6
|
Thanks again Bruce and everyone who added input.
Casey
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
caseyliska, You're welcome. Our pleasure.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
|
Guest-1 |