Market Cap to GDP is a long-term valuation indicator and as pointed by Warren Buffett, the indicator is “probably the best single measure of where valuations stand at any given moment.” It used as a broad way of assessing whether the country’s stock market is overvalued or undervalued, compared to a historical average.
Remark: The Wilshire W4500 and the S&P500 are indices and denoted in "index points" (not USD). The Original Buffett Indicator is using market cap in US-Dollar . So the right scale of the indicator is different to the original one.
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.