StockFetcher Forums · Filter Exchange · Polarized Fractal Efficiency<< >>Post Follow-up
srinisu
22 posts
msg #69994
Ignore srinisu
12/22/2008 8:07:02 PM

Can someone help me code this? Here is the code from eSignal, if that helps piece this together.

Provided By:

eSignal (Copyright c eSignal), a division of Interactive Data

Corporation. 2008. All rights reserved. This sample eSignal

Formula Script (EFS) is for educational purposes only and may be

modified and saved under a new file name. eSignal is not responsible

for the functionality once modified. eSignal reserves the right

to modify and overwrite this EFS file with each new release.



Description:

PFE (Polarized Fractal Efficiency)



Version: 1.0 10/14/2008



Notes:

The Polarized Fractal Efficiency (PFE) indicator measures the efficiency

of price movements by drawing on concepts from fractal geometry and chaos
theory. The more linear and efficient the price movement, the shorter the

distance the prices must travel between two points and thus the more efficient

the price movement.







Formula Parameters: Default:

**********************************/



var bInit = false;



function preMain() {

setStudyTitle("Polarized Fractal Efficiency");

setCursorLabelName("EMA", 0);

setDefaultBarFgColor(Color.aqua, 0);



addBand(50, PS_SOLID, 1, Color.blue);

addBand(-50, PS_SOLID, 1, Color.red);



}



var xEMA = null;

var xFracEff = null;





function main() {

var nBarState = getBarState();

var nEMA = 0;



if ( bInit == false ) {

xFracEff = efsInternal("Calc_FracEff");

xEMA = ema(5, xFracEff)

bInit = true;

}



nEMA = xEMA.getValue(0);

if (nEMA == null) return;



return nEMA;

}





function Calc_FracEff(){

var PFE = 0;

var C2C = 0;

var Counter = 0;

var FracEff = 0;

PFE = Math.sqrt(Math.pow((close(0) - close(-9)),2) + 100);

for (Counter = 1; Counter < 10; Counter++) {

C2C += Math.sqrt(Math.pow((close(-Counter + 1) - close(-Counter)), 2) + 1);

}

if ((close(0) - close(-9)) > 0) FracEff = Math.round((PFE / C2C) * 100);

else FracEff = Math.round(-(PFE / C2C) * 100);

if (FracEff == null) FracEff = 1;

return FracEff;

}

tomm1111
202 posts
msg #70007
Ignore tomm1111
modified
12/24/2008 1:40:30 AM

srinisu, Is this what you are looking for? How do you use the PFE in your trade?


Fetcher[
/* Polarized Fractal Efficiency */
set{var,close - close 9 days ago}
set{var1,abs(var)}
set{var2,var / var1}

set{hyp1,var}
set{hyp2,pow(hyp1,2)}
set{hyp3,100 + hyp2}
set{hypot,pow(hyp3,0.5)}

set{den,close - close 1 day ago}
set{den3,pow(den,2)}
set{den4,den3 + 1}
set{den5,pow(den4,0.5)}
set{den6,sum(den5,9)}

set{calc,var2 * hypot}
set{calc1,calc * 100}
set{pfe1,calc1 / den6}
set{pfe,cema(pfe1,5)}

add column pfe
draw pfe
draw pfe line at 100
draw pfe line at -100
draw pfe line at 0

show stocks where close is above 1
and volume is above 100000
]



chetron
2,817 posts
msg #70008
Ignore chetron
modified
12/24/2008 6:52:48 AM

CHEAP SEATS GET A WIN......

NO DRAWING ALLOWED....

UPDATED no roc....

Fetcher[

set{var,close - close 9 days ago}
set{var1,abs(var)}
set{var2,var / var1}

set{hyp1,VAR}
set{hyp2,pow(hyp1,2)}
set{hyp3,100 + hyp2}
set{hypot,pow(hyp3,0.5)}

set{den,close - close 1 days ago}
set{den3,pow(den,2)}
set{den4,den3 + 1}
set{den5,pow(den4,0.5)}
set{den6,sum(den5,9)}

set{calc,var2 * hypot}
set{calc1,calc * 100}
set{pfe1,calc1 / den6}

ADD COLUMN PFE1
DRAW PFE1

show stocks where close is above 1
and volume is above 100000
sort column 5 ascending



]



TheRumpledOne
6,407 posts
msg #70013
Ignore TheRumpledOne
12/24/2008 10:11:25 AM

Nice work!!

chetron
2,817 posts
msg #70029
Ignore chetron
12/24/2008 7:24:58 PM

BUT HOW DOES THIS COMPARE ?????????????

tomm1111
202 posts
msg #70032
Ignore tomm1111
12/25/2008 12:47:03 AM

...a few (special) egg nogs in, the pickled herring no longer in existence, and Mrs. Claus in the other room organizing gifts, I found a few minutes to post this description of the Polarized Fractal Efficiency (PFE). Chetron, I followed the link. They are similar in that they look for trend reversals. It looks like Alf has utilized the plethora of EMA's in his Range Contraction/Expansion filter. TRO, thx.

Merry Christmas to all!



PFE Description

The Polarized Fractal Efficiency indicator (PFE) was developed by Hans Hannula. It was introduced in the January 1994 issue of Technical Analysis of Stocks & Commodities magazine. As an engineer, programmer, and trader with over 30 years market experience, Mr. Hannula developed a unique approach to applying the laws of fractal geometry and chaos to the markets.


Interpretation

Drawing upon the pioneering works of mathematician Benoit Mendelbrot, Mr. Hannula developed an indicator to gauge the efficiency that prices travel between two points in time.

The more linear and efficient price movement, the shorter the distance the prices must travel between two points. The more "squiggly" the price movement, the less efficient it's travel.

The primary use of the PFE indicator is as a measure of how trendy or congested price action is. PFE readings above zero mean that the trend is up. The higher the reading the "trendier" and more efficient the upward movement. PFE readings below zero mean that the trend is down. The lower the reading the "trendier" and more efficient the downward movement. Readings around zero indicate choppy, less efficient movement, with a balance between the forces of supply and demand.

Several interesting phenomenon have been observed by Mr. Hannula:

* Indexes (particularly the OEX) tend to have a maximum PFE (both plus and minus) of about 43%.

* The middle region (around zero) is a balance between supply and demand and therefore a congestion point.

* A hooking pattern often occurs right before the end of an efficient period. This pattern occurs when the PFE appears to have maxed out, turns in the opposite direction towards zero, and then makes one last attempt at maximum efficiency. Trades can be entered in the opposite direction, with a stop just beyond the extreme of the hook. Stay with the trade all the way to the other extreme, unless it slows around the zero line. If it slows around zero, exit the trade and wait for a new maximum efficiency entry.




srinisu
22 posts
msg #70150
Ignore srinisu
12/30/2008 12:33:44 AM

The PFE has a wave like formation as it crests and you can use it with any other momentum indicator (I tend to use W%R) to initiate a short position. The reverse can be done when the wave is flat i.e. parallel to the x-axis.

Thanks to both folks who made an attempt to code it. Tom, with my susbcription, I'm unable to see the results, so I can't confirm it. Chetron, the shape of the PFE doesn't look right. I'm unable to deciher what is the issue, but PFE chart patterns are very different and are easily recognizable.

tomm1111
202 posts
msg #70215
Ignore tomm1111
modified
12/31/2008 1:06:30 AM

I compared this indicator with the PFE in TOS and it appears to be close. I see the shape of the waves as you describe them. As you already know, it requires the advance subscription.

srinisu
22 posts
msg #70464
Ignore srinisu
1/7/2009 10:04:14 PM

Hi Tom. Thanks for the follow-up. I have updated my subscription and I see the charts are identical to those on TOS. The values seem off though. Not a big deal.

E.g. 1/7/08
MSFT closed at 19.52
PFE on TOS: 63.015
PFE on StockFetcher: value is below 50

The difference could be how TOS does it or the code I gave you from eSignal. Either way, the work you have done is appreciated.

On a side note, since you use TOS, have you tried your programming skills on that?

I've been using the W%R(30) with a 9 day moving average and it has worked quite well for me. I'm not sure if your email id is listed here, else I'd send you an email with some images. My email ID: srinisu@gmail.com

tomm1111
202 posts
msg #70469
Ignore tomm1111
modified
1/8/2009 1:22:44 AM

I took another look at this. It looks like the "roc(x)" function was not giving me what I needed as it is represented as a percentage. I replaced them with "close - close (x) days ago" and it corrected the values. It is now the exactly the same as the TOS PFE.

The corrected filter is posted below and I modified the original post.

Fetcher[
/* Polarized Fractal Efficiency */
set{var,close - close 9 days ago}
set{var1,abs(var)}
set{var2,var / var1}

set{hyp1,var}
set{hyp2,pow(hyp1,2)}
set{hyp3,100 + hyp2}
set{hypot,pow(hyp3,0.5)}

set{den,close - close 1 day ago}
set{den3,pow(den,2)}
set{den4,den3 + 1}
set{den5,pow(den4,0.5)}
set{den6,sum(den5,9)}

set{calc,var2 * hypot}
set{calc1,calc * 100}
set{pfe1,calc1 / den6}
set{pfe,cema(pfe1,5)}

add column pfe
draw pfe
draw pfe line at 100
draw pfe line at -100
draw pfe line at 0

show stocks where close is above 1
and volume is above 100000
]




I've written some indicators for TOS. Most of them have been adaptations of the filter's here on SF and some other stuff. tomm1111@hotmail.com

StockFetcher Forums · Filter Exchange · Polarized Fractal Efficiency<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.