OPEN-SOURCE SCRIPT

Grenblatt Magic Formula

The magic formula is an investing strategy created by Joel Greenblatt that focuses on finding the best price to buy certain companies in order to maximize returns. When Greenblatt coined the term magic formula investing, his portfolio had a return of 24% from 1998 to 2009.

This means that $10,000 invested at 24% for the period would have turned into just over $1 million. A fund based on the S&P 500 index for the same period would have turned that $10,000 into just under $75,000.1

Note
Bigger returns matter, especially over long periods, due to the power of compounding.

Others who ran their own experiments were not able to duplicate Greenblatt's high returns but still yielded positive results. As a result, investing experts agree that the strategy of magic formula investing outperforms the indexes. In most cases, though, it doesn't seem to beat indexes by as much as Greenblatt indicated when he introduced the concept in his book, The Little Book That Beats the Market.

There are two ratios in the magic formula. The first is the earnings yield: EBIT /EV. This is earnings before interest and taxes divided by enterprise value.A simpler and more common version of this ratio is earnings /price. Greenblatt prefers EBIT over earnings , because EBIT more accurately compares companies with different tax rates. EV is preferred to share price because EV also factors in the company's debt. Therefore, EBIT /EV provides a better picture of overall earnings than earnings /price.

The second ratio is return on capital, which is EBIT /(Net Fixed Assets + Working Capital)

The first ratio looks at earnings before interest and taxes compared to enterprise value. The second ratio focuses on the earnings relative to tangible assets. Many assets listed on the balance sheet depreciate over time as their usefulness is used up. These types of assets are called "fixed assets."

Net fixed assets are fixed assets minus all the accumulated depreciation and any liabilities associated with the asset. This gives a more accurate sense of the real value of a company's assets, compared to just looking at the total asset number on the balance sheet . Working capital is also part of this ratio and is current assets minus current liabilities. This gives a picture of whether the company is likely able to continue operations in the short term.

While the two ratios in the magic formula look small, they actually are computing a lot of data about the inner workings of a company, including:

Earnings
Interest
Tax rates
Equity price
Debt
Depreciation of assets
Current assets
Current liabilities
Fundamental AnalysisValue

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer