AIAE Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rodopacapital

//@version=5
indicator("AIAE Indicator", overlay=false)


TMVS = request.security("WILL5000PRFC*1000000000", 'W', close) 
TMVB = request.security("FRED:GFDEBTN", 'W', close) 
C = request.security("FRED:M2SL", 'W', close) 



// Calculating Aggregate (or Average) Investor Allocation to Equities indicator in percents 
AIAE = TMVS/(TMVS+TMVB+C)

// Calculating Bonds indicator in percents 
BOND = TMVB/(TMVS+TMVB+C)

// Calculating other money indicator in percents 
other = C/(TMVS+TMVB+C)


// Calculating real stocks holdings in percents
stocks = TMVS/(TMVS+TMVB+C-(other*C))*100 
bonds = TMVB/(TMVS+TMVB+C)*100 


// Plot the global liquidity value as a candlestick chart
plot(stocks, "Stocks holdings as percent from total market", color = color.blue, trackprice=true)
plot(bonds, "Bonds holdings as percent from total market", color = color.red, display = display.none)
plot(other*100, "Other cash holdings as percent from total market", color = color.green, display = display.none)


