Joel Greenblatt Magic Formula

Joel Greenblatt Magic Formula. I always wanted to make this.
The Indicator shows 3 values.

ROC= Return On Capital.
EY=Earnings Yield
SUM= Addition of Two.

ROC=EBIT / (Net Working Capital + Net Fixed Assets).
EY = EBIT / Enterprise value
Enterprise Value=(Market value of equity + Net Interest-bearing debt)

To implement the strategy, investors start by identifying a universe of stocks, typically large-cap or mid-cap companies that trade on a major stock exchange. Next, they rank the stocks based on their ROC and EY. The companies with the best combination of these two metrics are considered the best investments (based on this ranking).
For example, a stock that ranks 10th on EY and 99th on ROIC gets a value of 109. The two ranks are simply added together and all stocks are ranked on the sum of the two ranks. The stocks with the lowest values are best.

All credits to "The Little Book That Beats The Market" by Joel Greenblatt

The Magic Formula strategy is a stock selection method popularized by Joel Greenblatt’s book The Little Book That Beats the Market.

It involves ranking companies based on Two factors:
A high return on capital and A high Earnings Yield.
The companies with the best combination of these two metrics are considered the best investments. The strategy aims to find undervalued companies with strong financials that have the potential for high returns over the long term.

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 a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?