Kaufman’s Efficiency Ratio (ER)

The Efficiency Ratio (ER) was first presented by Perry Kaufman in his 1995 book ‘Smarter Trading‘.  It is calculated by dividing the price change over a period by the absolute sum of the price movements that occurred to achieve that change.  The resulting ratio ranges between 0 and 1 with higher values representing a more efficient or trending market.

The ER is actually very similar to the Chande Momentum Oscillator (CMO) presented by Tushar S. Chande in ‘The New Technical Trader‘ (1994).  The difference is that the CMO takes into account for market direction but if you take the absolute CMO and divide by 100 you you get the Efficiency Ratio.

A measure of a trends strength can be very useful as some strategies work best on a trending market and some in a range bound market.  Likewise different moving average lengths will perform better depending on the market type at that time.

Kaufman originally intended the Efficiency Ratio for use in his Adaptive Moving Average (KAMA).  But in addition to the KAMA, as part of the Technical Indicator Fight for Supremacy we will be testing it as a component in a Variable Moving Average and an Indicator Weighted Moving Average.

.

How To Calculate the Efficiency Ratio

.

ER = Direction / Volatility

Where:

Direction = ABS (Close – Close[n])

Volatility = n ∑ (ABS(Close – Close[1]))

n = The efficiency ratio period.

Here is an example of a 3 period ER:

.

Efficiency Ratio Formula

.

Efficiency Ratio Excel File

.

I have put together an Excel Spreadsheet containing the Kaufman’s Efficiency Ratio and made it available for FREE download.  It contains a ‘basic’ version displaying the example above and a ‘fancy’ one that will automatically adjust to the length you specify.  Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Efficiency Ratio (ER).

.

Test Results

.
As part of the ‘Technical Indicator Fight for Supremacy‘ We have tested/will test the Efficiency Ratio as a component in several technical indicators:

  • Efficiency Ratio Variable Moving Average (ER-VMA) – CompletedResults
  • Efficiency Ratio Adaptive Moving Average (ER-AMA) – CompletedResults
  • Efficiency Ratio Log Normal Adaptive Moving Average (ER-LAMA)
  • Efficiency Ratio Weighted Moving Average (ER-WMA)

We will also test the ER as a filter, only taking trades when it indicates a strong trend.

.

Efficiency Ratio Example

.

Efficiency Ratio Example

Standard Deviation

Standard Deviation (SD) reveals how much a data set varies from its mean; a high Standard Deviation indicates that the data is widely spread.  With stock prices it can be used as a measure of the historical volatility to reveal the theoretical probability of a price change over a specified period.  This information can be used in many ways such as a measure of risk or as a component in technical indicators.

.

Normal Distribution Bell Curve

.

Normal Distribution - Bell Curve.

A data set that is Normally Distributed with produce a probability curve called a bell curve, like the one above.  One standard deviation from the mean accounts for 68% of the occurrences while two SDs covers 95% and three covers 99.7%.  One of the challenges with the stock market is that the data is not Normally Distributed but instead exhibits Fat Tails.  So the Standard Deviation is far from a perfect measure but is still a useful trading tool in some applications.

.

How To Calculate Standard Deviation

.

Standard deviation is the square root of variance and can easily be calculated in an Excel spread sheet with the =STDEVP() function or it can be done the hard way using the following formula:

.

Standard Deviation Formula

.

Where:

SMA = Simple Moving Average

N = Number of periods

.

Standard Deviation Example

.

If we take the percentage change of the Dow Jones Industrial Average for the 10 years from 2000 – 2010 we get the following values:

-6.17%,   -7.1%,   -16.76%,   25.32%,   3.15%,   -0.61%,   16.29%,   6.43%,   -33.84%,   18.82%

To find the SD we first find the mean (average):

(-6.17%  +   -7.1%  +  -16.76%  +  25.32%  +  3.15%  +  -0.61%  +  16.29%  +  6.43%  +  -33.84%  +  18.82%) / N

= 5.53% / 10

= 0.55%

We then calculate the deviation of each data point from the mean (= Data Point – Mean), square the result and find the sum:

-6.72%^2  +  -7.66%^2  +  -17.32%^2  +  24.77%^2  +  2.6%^2  +  -1.16%^2  +  15.73%^2  +  5.88%^2  +  -34.39%^2  +  18.27%^2

= 28.24%

Finally divide the result by N to find the average and take the square root to reveal the SD

= √(28.24% / 10)

= 16.8%

This means that in theory (assuming a normal distribution), based on ten years of the Dow’s annual price changes, about 68% of years the Dow will move up or down within 16.8% (one standard deviation).  While about 95% of years the Dow should finish up or down within 33.6% (two standard deviations).

What Does Standard Deviation Mean?
1. A measure of the dispersion of a set of data from its mean. The more spread apart the data, the higher the deviation. Standard deviation is calculated as the square root of variance.

2. In finance, standard deviation is applied to the annual rate of return of an investment to measure the investment’s volatility. Standard deviation is also known as historical volatility and is used by investors as a gauge for the amount of expected volatility.

Investopedia Says

Investopedia explains Standard Deviation
Standard deviation is a statistical measurement that sheds light on historical volatility. For example, a volatile stock will have a high standard deviation while the deviation of a stable blue chip stock will be lower.

Double (D-EMA) and Triple Exponential Moving Average (T-EMA)

The Double and Triple Exponential Moving Average were created by Patrick Mulloy and first published in the February 1994 issue of Technical Analysis of Stocks & Commodities magazine – Smoothing Data With Less Lag.  Mulloy stated in his article:

.

“Moving averages have a detrimental lag time that increases as the moving average length increases.  The solution is a modified version of exponential smoothing with less lag time.”

.

Like an EMA, the D-EMA and T-EMA apply more weight to the most recent data in an attempt to smooth out noise while still remaining highly reactive to changes in the data.  This is not achieved by simply double and triple smoothing as one may assume.  To do so results in weighting that resembles a backwards log-normal distribution, rather like a Triangular Moving Average but smooth and shifted forward.  Below you can see how the weighting is allocated by a single, double and triple smoothed exponential moving average compared to a standard EMA and SMA:

.

Double and Tripple Smoothed EMA Weighting.

As you can see by double and triple smoothing an EMA the weighting no longer focuses on the latest data.  The actual Double and Triple Exponential Moving Average applies the weighing very heavily to the most recent data as illustrated in the chart below:

.

Double and Tripple EMA Weight

.

How To Calculate a Double Exponential Moving Average and T-EMA

.

Double Exponential MA Formula:

D-EMA = 2*EMA – EMA(EMA)

Triple Exponential MA Formula:

T-EMA = (3*EMA – 3*EMA(EMA)) + EMA(EMA(EMA))

Where:

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

α = 2 / (N + 1)

N = The smoothing period.

Here is an example of a 3 period Double Exponential Moving Average and Triple EMA:

.

Double and Triple Exponential Moving Average Formula.

Triple Exponential Moving Average and D-EMA Excel File

.

We have built a spreadsheet to calculate the D-EMA and T-EMA and have made it available for free download.  Find the file at the following link near the bottom of the page under Downloads – Technical Indicators: Double (D-EMA) and Triple Exponential Moving Average (T-EMA).

.

Double EMA, Triple EMA and a Simple Moving Average

.

Double and Tripple EMA Vs a Simple MA.

 

Double and Triple Exponential Moving Average Test Results

 

 

We ran them through tests through over 300 years of data across 16 different global markets.  Here are the results:

Double Exponential Moving average Vs Simple and Exponential Moving average

 

Double Vs Triple Exponential Moving Average

 

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.

 

 

Triangular Simple Moving Average (TriS-MA)

The Triangular Simple Moving Average (TriS-MA) is almost identical to the Triangular Weighted Moving Average but is very different in how it is calculated.  Instead of weighting the data points directly it is a double smoothed simple moving average (a moving average of a moving average).  Because most of the weight ends up being placed on the data in the middle of a series the weighting looks like a triangle, hence the name.  Below you can see how the weighting is applied to a 50 period TriS-MA, EMA and SMA:

.

Triangular Simple MA vs SMA and EMA Weighting.

How To Calculate a Triangular Simple Moving Average

.

TriS-MA = SUM(MA1,L) / L

Where:

MA1 = SUM(CLOSE,L) / L

L = ceiling((n+1) / 2)

n = Number of Periods

Here is an example of a 3 period Triangular Weighted Moving Average:

.

How to Calculate a Triangular Simple Moving Average

.

Triangular Simple Moving Average Excel File

.

An Excel Spreadsheet containing a Triangular Weighted Moving Average is available for FREE download.  It contains the ‘basic’ version you can see above and a ‘fancy’ one that will automatically adjust to the length you specify.  Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Triangular Weighted Moving Average (TriW-MA).  Please let us know if you find it useful.

.

Triangular Moving Average and a Simple Moving Average

.

50 Day Triangular Simple MA and Simple MA.

Test Results

.

We tested several different types of Moving Averages including the TriS-MA through 300 years of data across 16 global markets to reveal which is the best and if any of them are worth using in your trading – see the results.

.

Exponential Moving Average (EMA)

The Exponential Moving Average (EMA) is a very popular method for smoothing data in an attempt to eliminate noise and our tests show that it is also highly effective.  Unlike the Simple Moving Average (SMA) that applies equal weight to all data, the EMA applies more weight to the recent data so that it reacts faster to sudden changes.

You can see see why it is called an Exponential Moving Average when you look at how the weighting is applied; it is in the shape of an exponential curve.  Because of this the weighting never reaches zero and the influence of early data always remains (although it has little effect outside of the specified smoothing period).  This is more clearly illustrated by the chart below which shows the weighting for a 50 period EMA and a SMA:

.

Weighting - Exponential Moving Average and a SMA.

Although we call it a 50 period EMA, those 50 periods only actually account for 86% of the weighting.  A further 12% is applied over the preceding 50 periods leaving the last 2% to be spread amongst all the prior data.  Here is a great article from MarketSci on this topic: Visual Depiction of SMA vs EMA Weighting

.

How To Calculate an Exponential Moving Average

.

Calculating an Exponential Moving Average actually requires less processing power than a Simple Moving Average because it only refers to the current period and the previous EMA value.  While it does not become active until the Nth period the EMA starts with the first close price and after that is calculated according to the following formula:

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

Where:

α = 2 / (N + 1)

N = The smoothing period.

Here is an example of a 3 period Exponential Moving Average:

.

How to Calculate an Exponential Moving Average

If you have two data sets and you wish to find out the EMA smoothing period, the following formula will reveal it:

N = (2-( (MA-MA[1]) / (Close-MA[1]) ) ) / ( (MA-MA[1]) / (Close-MA[1]) )

.

Exponential Moving Average Excel File

.

The EMA is so simple to calculate that it is unlikely that you would need a version in Excel but we have put together one for those of you that are lazy :).  It is free and contains the ‘basic’ version you can see above and one that will automatically adjust to the length you specify.  Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Exponential Moving Average (EMA).

.

Exponential Moving Average and a Simple Moving Average

.

Exponential Moving Average vs Simple MA.

Test Results

.

If you haven’t already then check out the EMA test results.  We tested it against the SMA and D-EMA through 300 years of data across 16 global markets to reveal which is the best and the characteristics they exhibit as their smoothing period is changed.  See the results; Moving Averages – Simple vs Exponential

.

Linear Regression Indicator (LRI) & Time Series Forecast (TSF)

Linear Regression is a statistical tool used to predict future values from past values.  By using the least squares method, a straight line can be plotted that minimizes the distance between the resulting line and the data set in order to reveal a trend.

The Linear Regression Indicator (LRI) plots the end value of a Linear Regression Line at each data point.  A variation on the same idea is the Time Series forecast (TSF) which is found by adding the Linear Regression Slope to the Linear Regression Line.  The TSF basically projects the LRI forward one period.  The TSF is also sometimes referred to as a Moving Linear Regression or Regression Oscillator.

By calculating these two indicators on a moving basis the result looks similar to that of a moving average and can be used in the same way.

.

Calculating a Linear Regression Line

.

Linear Regression Line = a + bx

Where:

a = (Σy – bΣx) / n

b = (nΣ(xy) – (Σx) (Σy)) / (nΣx² – (Σx)²)

b = Linear Regression Slope.

x = The current time period.

y = The data series (Usually the close price).

n = Number of periods.

.

Linear Regression Indicator & Time Series Forecast Excel File

.

Calculating these indicators by hand is a pain in the ass so we have build an Excel spreadsheet containing both the Linear Regression Indicator and Time Series forecast that you can download for free.  Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Linear Regression Indicator (LRI) & Time Series Forecast (TSF).  Please let us know if you find it useful.

.

Linear Regression Indicator, Time Series Forecast and a Simple Moving Average

.

Linear Regression Indicator, Time Series Forecast and SMA.

Test Results

.

We tested the Linear Regression Indicator and Time Series forecast through 300 years of data across 16 global markets to reveal which is the best and if either of them are worth using as trading tool for data smoothing – see the results.

.

.

Wilder’s Smoothing was developed buy J. Welles Wilder, Jr. and he used it as a component in several of his other indicators including the RSI which is one of the most popular technical indicators of all time.

Simple Moving Average (SMA)

The Simple Moving Average or SMA is probably the most commonly used technical indicator of all.  It can be calculated by taking the average of a data series (usually the close price) over a set number of periods.  As each period progresses the last value is dropped out of the calculation and the latest one takes its place; hence the ‘Moving’ characteristic.

Financial data is notorious for being full of noise.  Smoothing methods like averages help to filter out some of that noise so that a clearer picture of what is really going on can be revealed.  Test results show however the Simple Moving Average is certainly not the most effective smoothing method available.  Why then do we use the SMA in the weekly ETF HQ Report?

Some Simple Moving Averages such as the 50, 100 and 200 day SMA are so widely followed that they regularly become important support and resistance levels.  There is no reason why this should happen other than the fact that they have become a self fulfilling prophecy.  If enough people think that a level is important then it becomes important:

.

200 Day Simple Moving Average as Support.

Above is an example the 200 day SMA acting as support and being seen as a buying opportunity for over a year.  With so many points of inflection on this average the eventual break was viewed by traders as a significant technical failure and a flood of selling ensued.

For those of you who use Excel in your trading I have built a spreadsheet for you that contains a simple moving average.  You are probably wondering why you would want to download such a simple indicator but this one is useful because it will automatically adjust to the length that you specify.  We find this a useful feature and hopefully you will as well.  Get the file at the following link near the bottom of the page under Downloads – Technical Indicators: Simple Moving Average (SMA).  Please let us know if you find it useful.

.

Moving Average Test Results

.

Have you ever wondered which is better; a simple or exponential moving average?  Well we tested both along with a double exponential moving average through 300 years of data across 16 global markets to reveal the answer.  Here are the results – Simple vs. Exponential Moving Average

.

Sine Weighted Moving Average (SW-MA)

The Sine Weighted Moving Average is being tested along with many other indicators in the ‘Technical Indicator – Fight for Supremacy‘.  It is not an indicator that many people will be familiar with so I will briefly cover how it is calculated and have also built the Sine Weighted Moving Average into an Excel Spreadsheet for free download.

A Sine wave is a smooth, repetitive oscillation that shifts between a high of y and a low of -y.  A SW-MA takes its weighting from the first half of a Sine wave cycle so the largest weighting is given to the data in the middle.  The result is very similar to the Triangular Moving Average (Tri-MA) but much more difficult to calculate.  Below you can see how the weighting is applied to a 50 period SW-MA, EMA and SMA:

.

Weight - SW-MA vs EMA vs SMA

.

How To Calculate a Sine Weighted Moving Average

.

To calculate the Sine Weighted Moving Average multiply the sine value for each period by the close price for that period, add it all up and divide the result by the sum of the sine weights.  As a formula it looks like this:

.

Sine Weighted Moving Average Formula.

Here is an example of a 3 period Sine Weighted Moving Average:

.

Calculating a Sine Weighted Moving Average

.

Sine Weighted Moving Average Excel File

.

An Excel Spreadsheet containing a Sine Weighted Moving Average is available for FREE download.  It contains the ‘basic’ version you can see above and a ‘fancy’ one that will automatically adjust to the length you specify.  Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Sine Weighted Moving Average (SW-MA).  Please let us know if you find it useful.

.

Sine Weighted Moving Average and a Simple Moving Average

.

Sine Weighted Moving Average and a Simple MA

.

Test Results

.

We tested several different types of Weighted Moving Averages including the SW-MA through 300 years of data across 16 global markets to reveal which is the best and if any of them are worthy of use as a trading tool.  See the results – Weighted Moving Averages Put To The Test

.

.

Wilder’s Smoothing was developed buy J. Welles Wilder, Jr. and he used it as a component in several of his other indicators including the RSI which is one of the most popular technical indicators of all time.
Wilder’s Smoothing was developed buy J. Welles Wilder, Jr. and he used it as a component in several of his other indicators including the RSI which is one of the most popular technical indicators of all time.

Triangular Moving Average (TriW-MA)

The Triangular Weighted Moving Average (TriW-MA) is included in the ‘Technical Indicator – Fight for Supremacy‘ so before we test it here is some information on how it is calculated.  If you would like to use the Triangular Moving Average in Excel then you can download a free spreadsheet HERE.

The TriW-MA gets it name from the way it applies the weight to data; because the emphasis is on the values in the middle, the weighting takes the shape of a triangle.  Below you can see how the weighting is applied to a 50 period TriW-MA, EMA and SMA:

.

Weight - TriW-MA vs EMA vs SMA

.

How To Calculate a Triangular Weighted Moving Average

.

To calculate a Triangular Weighted Moving Average multiply each close price by the weight for that period, add it all up and divide the result by the sum of the weights.  The weighting multiplier starts at 1 and increases by 1 until it peaks half way through the set before decreasing symmetrically back down to finish at 1 again.

Here is an example of a 3 period Triangular Weighted Moving Average:

.

Calculating a Triangular Weighted Moving Average

.

The same result can be achieved by using a double smoothed moving average AKA the Triangular Simple Moving Average.

.

Triangular Weighted Moving Average Excel File

.

An Excel Spreadsheet containing a Triangular Weighted Moving Average is available for FREE download.  It contains the ‘basic’ version you can see above and a ‘fancy’ one that will automatically adjust to the length you specify.  Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Triangular Weighted Moving Average (TriW-MA).  Please let us know if you find it useful.

.

Triangular Moving Average and a Simple Moving Average

.

Triangular Weighted Moving Average and a Simple MA

.

Test Results

.

We tested several different types of Weighted Moving Averages including the TriW-MA through 300 years of data across 16 global markets to reveal which is the best and if any of them are worth using in your trading systems.  See the results – Weighted Moving Averages Put To The Test

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