Inflation adjusted "if had had invested for X years" chart

The purpose of this chart is to investigate how long you need to invest in the DJIA to overcome the noise created by fluctuations in the market. What you are seeing is an inflation adjusted chart showing your yield per year if you had invested for 20,10 and 5 years respectively. It seems like 20 year investments usually show pretty good returns but not 100% of the time and past performance is not a promise of future results.

The formula I used for yield per year is "yield / (# of years)". This does not give you the compound interest rate, for that you need 100 * ((yield / 100)^(1 / (# of years)) - 1), I don't know how to take the nth root of a number with Tradingview's scripting language if one of you knows please enlighten me.

This is a conversion chart made with excel. Example when the 20 year chart says 30 it really means 600% gain over 20 years which is 7Xing your investment, this is a compound interest rate of 10.22%