FRAMA – Is It Effective?

The Fractal Adaptive Moving Average aka FRAMA is a particularly clever indicator.  It uses the Fractal Dimension of stock prices to dynamically adjust its smoothing period.  In this post we will reveal how the FRAMA performs and if it is worthy of being included in your trading arsenal.

To fully understand how the FRAMA works please read this post before continuing.  You can also download a FREE spreadsheet containing a working FRAMA that will automatically adjust to the settings you specify.  Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Fractal Adaptive Moving Average (FRAMA).  Please leave a comment and share this post if you find it useful.

The ‘Modified FRAMA’ that we tested consists of more than one variable.  So before we can put it up against other Adaptive Moving Averages to compare their performance, we must first understand how the FRAMA behaves as its parameters are changed.  From this information we can identify the best settings and use those settings when performing the comparison with other Moving Average Types.

Each FRAMA requires a setting be specified for the Fast Moving Average (FC), Slow Moving Average (SC) and the FRAMA period itself.  We tested trades going Long and Short, using Daily and Weekly data, taking End Of Day (EOD) and End Of Week (EOW) signals~ analyzing all combinations of:

FC = 1, 4, 10, 20, 40, 60

SC = 100, 150, 200, 250, 300

FRAMA = 10, 20, 40, 80, 126, 252

Part of the FRAMA calculation involves finding the slope of prices for the first half, second half and the entire length of the FRAMA period.  For this reason the FRAMA periods we tested were selected due to being even numbers and the fact that they correspond with the approximate number of trading days in standard calendar periods: 10 days = 2 weeks, 20 days = 1 month, 40 days = 2 months, 80 days = ⅓ year, 126 days = ½ year and there are 252 trading days in an average year.  A total of 920 different averages were tested and each one was run through 300 years of data across 16 different global indexes (details here).

Download A FREE Spreadsheet With Raw Data For

All 920 FRAMA Long and Short Test Results

.

FRAMA – Test Results:

.

Best FRAMA Parameters

A Slower FRAMA

FRAMA Testing – Conclusion

.

Daily vs Weekly Data – EOD vs EOW Signals

.

In our original MA test; Moving Averages – Simple vs. Exponential we revealed that once an EMA length was above 45 days, by using EOW signals instead of EOD signals you didn’t sacrifice returns but did benefit from a 50% jump in the probability of profit and double the average trade duration.  To see if this was also the case with the FRAMA we compared the best returns produced by each signal type:

.

FRAMA - Best Returns by Signal Type

As you can see, for the FRAMA, Daily data with EOD signals produced by far the most profitable results and we will therefore focus on this data initially.  It is presented below on charts split by FRAMA period with the test results on the “y” axis, the Fast MA (FC) on the “x” axis and a separate series displayed for each Slow MA (SC).

Return to Top

.

FRAMA Annualized Return – Day EOD Long

.

FRAMA - Annualized Return, Long

.

The first impressive thing about the results above is that every single Daily EOD Long average tested outperformed the buy and hold annualized return of 6.32%^ during the test period (before allowing for transaction costs and slippage).  This is a strong vote of confidence for the FRAMA as an indicator.

You will also notice that the data series on each chart are all bunched together revealing that similar results are achieved despite the “SC” period ranging from 100 to 300 days.  Changing the other parameters however makes a big difference and returns increase significantly once the FRAMA period is above 80 days.  This indicates that the Fractal Dimension is not as useful if measured over short periods.

When the FRAMA period is short, returns increase as the “FC” period is extended.  This is due to the Fractal Dimension being very volatile if measured over short periods and a longer “FC” dampening that volatility.  Once the FRAMA period is 40 days or more the Fractal Dimension becomes less volatile and as a result, increasing the “FC” then causes returns to decline.

Overall the best annualized returns on the Long side of the market came from a FRAMA period of 126 days which is equivalent to about six months in the market, while a “FC” of just 1 to 4 days proved to be most effective.  Assessing the results from the Short side of the market comes to the same conclusion although the returns were far lower: FRAMA Annualized Return – Short.

Return to Top

.

FRAMA Annualized Return During Exposure – Day EOD Long

.

FRAMA, Annualized Return During Exposure - Long.

The above charts show how productive each different Daily FRAMA EOD Long was while exposed to the market.  Clearly the shorter FRAMA periods are far less productive and anything below 40 days is not worth bothering with.  The 126 day FRAMA again produced the best returns with the optimal “FC” being 1 – 4 days.  Returns for going short followed a similar pattern but as you would expect were far lower; FRAMA Annualized Return During Exposure – Short.

Moving forward we will focus in on the characteristics of the 126 Day FRAMA because it consistently produced superior returns.

Return to Top

.

FRAMA, EOD – Time in Market

.

FRAMA, Market Exposure - Long and Short.

Because the 16 markets used advanced at an average annualized rate of 6.32%^ during the test period it doesn’t come as a surprise that the majority of the market exposure was to the long side.  By extending the “FC” it further increased the time exposed to the long side and reduced exposure on the short side.  If the test period had consisted of a prolonged bear market the exposure results would probably be reversed.

Return to Top

.

FRAMA, EOD – Trade Duration

.

126 Day FRAMA, Average Trade Duration - Long & Short

.

By increasing the “FC” period it also extends the average trade duration.  Changing the “SC” makes little difference but as the “SC” is raised from 100 to 300 days the average trade duration does increase ever so slightly.

Return to Top

.

FRAMA, EOD – Probability of Profit

.

126 Day FRAMA, Probability of Profit - Long & Short

.

As you would expect, the probability of profit is higher on the long side which again is mostly a function of the global markets rising during the test period.  However the key information revealed by the charts above is that the probability of profit decreases significantly as the “FC” is extended.  This is another indication that the optimal FRAMA requires a short “FC” period.

Return to Top

.

The Best Daily EOD FRAMA Parameters

.

Our tests clearly show that a FRAMA period of 126 days will produce near optimal results.  While for the “SC” we have shown that any setting between 100 and 300 days will produce a similar outcome.  The “FC” period on the other hand must be short; 4 days or less.  John Ehlers’ original FRAMA had a “FC” of 1 and a “SC” of 198; this will produce fantastic results without the need for any modification.

Because we prefer to trade as infrequently as possible we have selected a “FC” of 4 and a “SC” of 300 as the best parameters because these settings results in a longer average trade duration while still producing great returns on both the Long and Short side of the market:

.

FRAMA, EOD – Long

.

126 Day FRAMA, EOD 4, 300 Long

.

Above you can see how the 126 Day FRAMA with a “FC” of 4 and a “SC” of 300 has performed since 1991 compared to an equally weighted global average of the tested markets.  I have included the performance of the 75 Day EMA, EOW becuase it was the best performing exponential moving average from our original tests.

This clearly illustrates that the Fractal Adaptive Moving Average is superior to a standard Exponential Moving Average.  The FRAMA is far more active however producing over 5 times as many trades and did suffer greater declines during the 2008 bear market.

.

FRAMA, EOD – Short

.

126 Day FRAMA, EOD 4, 300 Short

.

On the Short side of the market the FRAMA further proves its effectiveness.  Without needing to change any parameters the 126 Day FRAMA, EOD 4, 300 remains a top performer.  When we ran our original tests on the EMA we found a faster average worked best for going short and that the 25 Day EMA was particularly effective.  But as you can see on the chart above the FRAMA outperforms again.

What is particularly note worthy is that the annualized return during the 27% of the time that this FRAMA was short the market was 6.64% which is greater than the global average annualized return of 6.32%.

.

126 Day FRAMA, EOD 4, 300 - Long and Short on Tested MarketsSee the results for the 126 Day FRAMA, EOD 4, 300
Long and Short on each of the 16 markets tested.

Return to Top

.

126 Day FRAMA, EOD 4, 300 – Smoothing Period Distribution

.

With a standard EMA the smoothing period is constant; if you have a 75 day EMA then the smoothing period is 75 days no matter what.  The FRAMA on the other hand is adaptive so the smoothing period is constantly changing.  But how is the smoothing distributed?  Does it follow a bell curve between the “FC” and “SC”, is it random or is it localized around a few values.  To reveal the answer we charted the percentage that each smoothing period occurred across the 300 years of test data:

.

126 Day FRAMA, EOD 4, 300 - Smoothing Period Distribution.

The chart above came as quite a surprise.  It reveals that despite a “FC” to “SC” range of 4 to 300 days, 72% of the smoothing was within a 4 to 50 day range and the majority of it was only 5 to 8 days.  This explains why changing the “SC” has little impact and why changing the “FC” makes all the difference.  It also explains why the FRAMA does not perform well when using EOW signals, as an EMA must be over 45 days in duration before EOW signals can be used without sacrificing returns.

Return to Top

.

A Slower FRAMA

.
We have identified that the FRAMA is a very effective indicator but the best parameters (126 Day FRAMA, EOD 4, 300 Long) result in a very quick average that in your tests had an typical trade duration of just 14 days.  We also know that the 75 Day EMA, EOW Long is an effective yet slower moving average and in our tests had a typical trade duration of 74 days.

A good slow moving average can be a useful component in any trading system because it can be used to confirm the signals from other more active indicators.  So we looked through the FRAMA test results again in search a less active average that is a better alternative to the 75 Day EMA and this is what we found:

.

252 Day FRAMA, EOW 40, 250 Long.

The 252 Day FRAMA, EOW 40, 250 Long produces some impressive results and does out perform the 75 Day EMA, EOW Long by a fraction.  However this fractional improvement is in almost every measure including the performance on the short side.  The only draw back is a slight decrease in the average trade duration from 74 days to 63 when long.  As a result the 252 Day FRAMA, EOW 40, 250 has knocked the 75 Day EMA, EOW out of the Technical Indicator Fight for Supremacy.

.

252 Day FRAMA, EOW 40, 250 - Long and Short on Tested Markets
See the results for the 252 Day FRAMA, EOW 40, 250
Long and Short on each of the 16 markets tested.

Return to Top

.

252 Day FRAMA, EOW 40, 250 – Smoothing Period Distribution

.

252 Day FRAMA, EOW 40, 250 - Smoothing Period Distribution.

Return to Top

.

FRAMA Testing – Conclusion

.

The FRAMA is astoundingly effective as both a fast and a slow moving average and will outperform any SMA or EMA.  We selected a modified FRAMA with a “FC” of 4, a “SC” of 300 and a “FRAMA” period of 126 as being the most effective fast FRAMA although the settings for a standard FRAMA will also produce excellent results.  For a slower or longer term average the best results are likely to come from a “FC” of 40, a “SC” of 250 and a “FRAMA” period of 252.

Robert Colby in his book ‘The Encyclopedia of Technical Market Indicators’ concluded, “Although the adaptive moving average is an interesting newer idea with considerable intellectual appeal, our preliminary tests fail to show any real practical advantage to this more complex trend smoothing method.”  Well Mr Colby, our research into the FRAMA is in direct contrast to your findings.

It will be interesting to see if any of the other Adaptive Moving Averages can produce better returns.  We will post the results HERE as they become available.

Well done John Ehlers you have created another exceptional indicator!

.

More in this series:

We have conducted and continue to conduct extensive tests on a variety of technical indicators.  See how they perform and which reveal themselves as the best in the Technical Indicator Fight for Supremacy.

 

Return to Top

.

 

 

 

 

 

 

 

 

  • ~ An entry signal to go long (or exit signal to cover a short) for each average tested was generated with a close above that average and an exit signal (or entry signal to go short) was generated on each close below that moving average.  No interest was earned while in cash and no allowance has been made for transaction costs or slippage.  Trades were tested using End Of Day (EOD) and End Of Week (EOW) signals for Daily data and EOW signals for Weekly data. Eg. Daily data with an EOW signal would require the Week to finish above a Daily Moving Average to open a long or close a short while Daily data with EOD signals would require the Daily price to close above a Daily Moving Average to open a long or close a short and vice versa.
  • ^ This was the average annualized return of the 16 markets during the testing period. The data used for these tests is included in the results spreadsheet and more details about our methodology can be found here.

Fractal Adaptive Moving Average (FRAMA)

FRAMA stands for Fractal Adaptive Moving Average and we have classed it as a Log-Normal Adaptive Moving Average (LAMA).  Created by John F Ehlers (See his original paper or the article from the 2005 edition from Technical Analysis of Stocks and Commodities – Fractal Adaptive Moving Averages), it utilizes Fractal Geometry in an attempt to dynamically adjust its smoothing period to suit the changing price action over time.  The FRAMA theory is extremely clever, but clever theories don’t guarantee good results so we are putting the concept into the ring for the ‘Technical Indicator – Fight for Supremacy‘.

But before we go any further it is important that we understand what we are testing.  So I will explain how the FRAMA works although I must admit it is a bit above the the maths education that I didn’t pay attention to in school.  Also we have put together a free excel spreadsheet containing the Fractional Adaptive Moving Average so you can test it for yourself.

(If you would rather skip the maths then jump to the completed test results here – Is the FRAMA Effective?)

.

FRAMA Topics

.

Test Results – Is the FRAMA Effective?

.

How The FRAMA Works

.

First of all the FRAMA takes advantage of the fact that financial markets are fractal.  A fractal shape is said to be rough or fragmented and can be split into parts, each of which is at least similar to a reduced size copy of the original.  Example: Can you see anything strange about the chart below?

.

The Markets are Fractal.

Without being told would you have known that the left half of the chart above was 5 years of monthly bars and the right half was 15 days on 30 minute bars?  Probably not, because price movements look similar no matter what time frame we are viewing them in.  This characteristic is called self-similarity and defines a fractal shape.

By finding the Fractal Dimension or “D” we get an indication as to how completely a Fractal appears to fill space as one zooms down to finer and finer scales.  Think of it this way: A stock chart is too big to be one dimensional but too thin to be two dimensional so its Fractal Dimension is a reading between one and two.

(For a more in depth look into Fractals and “D” please read this post – The Fractal Dimension)

The FRAMA identifies the Fractal Dimension of prices over a specific period and then uses the result to dynamically adapt the smoothing period of an exponential moving average.

Return to Top

.

Finding The Fractal Dimension of a Shape

.

To find the Fractal Dimension “D” of a shape we cover it with a number “F” of small objects that are various sizes “S”:

D = Log(F2 / F1) / Log(S1 / S2)

What is Log?

For those of you like me who didn’t pay attention in maths class ‘Log’ is short for Logarithm and is the power that a number needs to be raised to in order to produce a given result.  Unless otherwise stated the base number is 10, therefore:

Log(1000) = 3

Because

10^3 = 10 * 10 * 10

10^3 = 1000

After that quick maths lesson lets calculate the Fractal Dimension for a line segment that is 10 meters long.  First select two small dimensions such as S1 = 1 meter and S2 = 0.1 meters.  By placing boxes of these sizes on the line segment we can fit 10 of the one meter size and 100 of the 0.1 meter size.  So F1 = 10 and F2 = 100.  Therefore:

D = Log(F2 / F1) / Log(S1 / S2)

D = Log(100 / 10) / Log(1 / 0.1)

D = Log(10) / Log(10)

D = 1 / 1

D = 1

Because D = 1 we have revealed that the Fractal exists fully in one Dimension which makes sense because the measured shape was just a flat line.

For a second example instead of a flat line lets use a square that is 10 x 10 meters.  Keeping S1 and S2 the same we now get F1 = 100 and F2 = 10,000 therefore:

D = Log(F2 / F1) / Log(S1 / S2)

D = Log(10,000 / 100) / Log(1 / 0.1)

D = Log(100) / Log(10)

D = 2 / 1

D = 2

Because D = 2 we have revealed that the Fractal has completely filled two dimensions which makes sense as the measured shape was a square and a square requires two dimensions to exist.

Unfortunately stock prices lack this regularity but are still self similar.  So, in order to discover the “D” of stock prices we must average the measured Fractal Dimension over different scales.

Covering a price curve with a series of small boxes is far too cumbersome but because price samples are uniformly spaced (each bar is 1 day, 1 week, 10 min etc) Ehlers decided that the average slope of the curve could be used as an estimation of the box count.  This is far less complicated than it sounds as the slope is found by simply taking the highest price over a period minus the lowest price during that period and dividing the result by the number of periods.  We will call this measure “HL”, therefore:

HL = (Max(High,N) – Min(Low,N)) / N

N = Periods

We will need to find the “HL” measure (slope) over the first half, second half and full length of “N” to help us find “D”, clear as mud?

Return to Top

.

How to Calculate a Fractal Adaptive Moving Average

.

It starts with the Close price.

FRAMA(N-1) = Close

After that FRAMA is calculated according to the following formula:

FRAMA = FRAMA(1) + α * (Close – FRAMA(1))

You will notice that this is the same as the formula for an Exponential Moving Average (EMA):

EMA = EMA(1) + α * (Close – EMA(1))

But Alpha in an EMA is α = 2 / (N + 1) so it remains constant while for the FRAMA α = EXP(W*(D – 1)) making it adapt as the Fractal Dimension changes.

What is EXP?

EXP is known as the Exponential Function, it is like Log but instead of an assumed base of 10 it has a base of “e”.  So x = Log(10^x) and x = EXP(e^x) where “e” is approximately 2.718281828.  Confused yet?  “e” is a unique number because the slope of its curve is 1 when x = 0 and it solves the compound interest problem.

Didn’t know there was a problem with compound interest?  Neither did I.

You see if you invest $1 at an interest rate of 100% calculated annually, at the end of the first year you will have $2; simple.  But if you compound the interest during the year it gets a bit more complicated.  When interest is compounded every 6 months you can find the result for the year by multiplying $1 by 1.5 twice, so $1.00 × 1.5^2 = $2.25.  If the interest is compounded quarterly then the result is $1.00 × 1.25^4 = $2.44, and monthly it is $1.00 × 1.0833…^12 = $2.613035….

Notice how each time you increase the frequency of compounding you get a larger result?  This is the ‘compound interest problem’.  However if you invest $1 with a return of 100% each year and the interest is compound constantly then the result is ‘e’.

So why did Ehlers use EXP?

If a number “Y” has a random variable with a Normal Distribution then EXP(Y) has a Log-Normal Distribution.  Stock prices are said to be Log-Normal so EXP is used to relate the Fractal Dimension to Alpha.  Keep reading this will make more sense soon…

What is Log-Normal and why does it describe stock prices?

(In theory) the percentage change to achieve possible future stock prices at the end of a period is Normally Distributed.  That is; the change will result in a positive or negative return and 95% of the outcomes should fall within two standard deviations of the mean.  (In reality price changes aren’t normally distributed – Michael Stokes explains Fat Tails)

The possible prices that will result from those changes can range from zero and infinity.  This is because a stock can’t drop more than 100% as that would result in a negative price but a it can more than double.  Therefore prices are said to be Log-Normal.  This concept really confused me at first but a picture is worth a 1000 words so:

.

Stock Prices are Log-Normal.

To show that stock prices are roughly Log-Normal I calculated the price change over the prior year for the last 10,000 market days on the Dow.  In theory these results are Normally Distributed so by finding their EXP and plotting the frequency each result occurs, the above chart reveals the most probable closing prices for the Dow in one years time.

Now if a number “Y” is Log-Normal, then Log(Y) will be Normally Distributed.  So if stock prices are indeed Log-Normal then by taking the Log of the price changes on the above chart we should get something that looks like a bell curve:

.

Price Changes are Normally Distributed

.

Above you can see a bell curve (all be it an ugly one) that displays the probability of any percent chance on the Dow over the next year between -20% and 25%.  So hopefully that explains what Log-Normal is and why it is a characteristic of stock prices… Here ends the maths lesson.

Return to Top

.

How to Calculate a Fractal Adaptive Moving Average – Continued

.

FRAMA = FRAMA(1) + α * (Close – FRAMA(1))

Where:

α = EXP(W * (D – 1))

D = (Log(HL1 + HL2) – Log(HL)) / Log(2)

Note: Log(2) = Log(N / (½N))

HL1 = (Max(High,½N..N) – Min(Low,½N..N)) / ½N

HL2 = (Max(High,½N) – Min(Low,½N)) / ½N

HL = (Max(High,N) – Min(Low,N)) / N

N = FRAMA Period, must be an even number.

W = -4.6 (Set by Ehlers but can be changed.  See: Modified FRAMA)

If Alpha < 0.01  then Alpha = 0.01

If Alpha > 1 then Alpha = 1

Return to Top

.

Finding The Fractal Dimension, Examples

.

Lets have a look at some theoretical stock prices and the resulting Fractal Dimension:

.

FRAMA, "D" - Example

.

Above are three price curves, now lets calculate the “D” for each where “N” = 100.

D = (Log(HL1 + HL2) – Log(HL)) / Log(2)

So:

FRAMA Calculating "D"

.

For ‘Curve A’ the full range is repeated in both halves of the chart so it exists fully in two Dimensions and D = 2.  For ‘Curve B’ only half of the range is repeated in each half of the chart so it exists in between one and two Dimensions or specifically D = 1.58.  The range for ‘Curve C’ is not repeated at all between the two halves of the chart so it exists in only one Dimension and D = 1.

Return to Top

.

How does the Fractal Dimension “D” affect the Smoothing Period “N”?

.

The FRAMA adapts between being a Fast or Slow EMA based in the Fractal Dimension of stock prices.  Ehlers designed the slowest possible EMA to be approximately 200 periods in duration and the fastest to have a period of one or in other words be equal to the price itself.  So for the three curves from our previous example, lets see how “D” changes “α” and how that affects “N” or the smoothing period of the resulting EMA:

α = EXP(W*(D – 1))

N (EMA) = (2 – α) / α

(Ehlers set “W” as -4.6, but it can be changed. See: Modified FRAMA)

.

How "D" Affects "α" and Resulting "N".

When D = 2 as with ‘Curve A’ the result is an Slow EMA of 198 periods while when D = 1 as with ‘Curve C’ the result is a Fast EMA of one period (the close price itself).

.

“This adaptive structure rapidly follows major changes in price and slowly changes when the prices are in a congestion zone.” – John Ehlers

Return to Top

.

Modified FRAMA

.

Ehlers rigidly set the FRAMA to shift between a Fast EMA of 1 period (lets call it FC) and a Slow EMA of 198 days (lets call it SC).  But because we are going to be entering the FRAMA in the ‘Technical Indicator – Fight for Supremacy‘ I wanted to be able to specifically define the “FC” and “SC” of my choice.

Special thanks to Prospectus – “Real Rocket Scientist, Wanna-be Trader” for his help on this section, be sure to subscribe to his blog and follow him on twitter.

So instead of setting “W” as -4.6 as Ehlers did, lets make W = LN(2 / (SC + 1)).  This results in a FRAMA that shifts between a “FC” of 1 and a “SC” of your choice.  For example where SC = 200, W = -4.61015.  Ehlers obviously rounded this off hence his setting of -4.6.

What is LN and why do we use it to find “W”?

LN is an abbreviation for ‘Natural Logarithm’ and is the inverse of EXP; so if EXP(1) = x then LN(x) = 1.  Because EXP is used to relate the Fractal Dimension to Alpha, LN is used to find “W”.

Now in order to set the Fast MA or “FC” of your choice simply take the resulting EMA period “N” and adjust it to fit the new range.  For example if SC = 100 and the resulting N = 50 but instead of the standard SC = 1 we want to change it to SC = 20, the following formula will reveal the “New N”:

New N = ((SC – FC) * ((Origional N – 1) / (SC – 1))) + FC

New N = ((100-20) * ((50 – 1) / (100 – 1))) + 20

New N = (80 * (49 / 99)) + 20

New N = 60

This is then easily converted back into Alpha:  New α = 2 / (New N + 1)

Modified FRAMA additional rules:

SC = Your choice of a Slow moving average > FC

FC = Your choice of a Fast moving average < SC

If Alpha < 2 / (SC + 1)  then Alpha = 2 / (SC + 1)

If Alpha > 1 then Alpha = 1

FRAMA(N-1) = SUM(CLOSE, H)/H

H = EVEN( ((SC – FC) / 2) ) + FC

If N-1 < EVEN( ((SC – FC) / 2) ) + FC then H = N-1

Return to Top

.

FRAMA Excel File

.

We have put together an Excel Spreadsheet containing the FRAMA and made it available for FREE download.  It contains a ‘basic’ version of John Ehlers FRAMA and our Modified version along with a ‘fancy’ one that will automatically adjust to the settings that you specify.  Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Fractal Adaptive Moving Average (FRAMA).  Please let me know if you find it useful.

.

FRAMA and a Simple Moving Average

.

FRAMA and a Simple Moving Average

Return to Top

.

Fractal Adaptive Moving Average Test Results

.
We tested the FRAMA through 300 years of data across 16 global markets, see the results now – Is the FRAMA Effective?
.
.
.

Michael Stokes explains why – Fat Tails