Index Value Rainbow
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © danny_peanuts
// 
// Index value based on Base Money Supply
//
// Currently can be used to estimate the value of largest indices by market cap:
//      - US Index - based on Net Liquidity (SPX, NDX, DJI, RUI, RUT, RUA, ES1!, NQ1!, YM1!, RTY1!)
//      - EU Index - based on M1 Money Supply (N100, EU500, SXXP, SX5E, DAX, CAC40)
//      - UK Index - based on M0 Money Supply (FTSE100, UK100)
//      - JP Index - based on M0 Money Supply (NI225, NKY)
//      - CN Index - based on M0 Money Supply (000001, 399001)
//      - HK Index - based on M0 Money Supply (HSI)
//      - SG Index - based on M0 Money Supply (STI)
//      - CA Index - based on M0 Money Supply (TSX)
//      - AU Index - based on M0 Money Supply (ASX200, AUS200)
//      - ID Index - based on M0 Money Supply (COMPOSITE)
//
//@version=5
indicator("Index Value Rainbow", overlay = true)
// Net Liquidity = FHLB Balance Sheet + Fed Balance Sheet - Treasury General Account - Reverse Repo (more accurate than M0 data)
USM0 = request.security("(BOGZ1FL403069330Q + WALCL - WTREGEN - RRPONTSYD)", "D", close)
// M0 = 0.65 M1 (estimated value because there is no M0 data)
EUM0 = 0.65 * request.security("EUM1", "D", close)
GBM0 = request.security("GBM0", "D", close)
CNM0 = request.security("CNM0", "D", close)
JPM0 = request.security("JPM0", "D", close)
HKM0 = request.security("HKM0", "D", close)
SGM0 = request.security("SGM0", "D", close)
CAM0 = request.security("CAM0", "D", close)
AUM0 = request.security("AUM0", "D", close)
IDM0 = request.security("IDM0", "D", close)
V = 0 * USM0
if syminfo.ticker == "RUI" or syminfo.ticker == "RUT" or syminfo.ticker == "RUA" or syminfo.ticker == "RTY1!"
    V := 1 * USM0 / 10000000000
if syminfo.ticker == "SPX" or syminfo.ticker == "ES1!"
    V := 1 * USM0 / 10000000000
if syminfo.ticker == "NDX" or syminfo.ticker == "NQ1!"
    V := 2.5 * USM0 / 10000000000
if syminfo.ticker == "DJI"  or syminfo.ticker == "YM1!"
    V := 10 * USM0 / 10000000000
if syminfo.ticker == "N100" or syminfo.ticker == "EU500"
    V := 5 * EUM0 / 100000000000
if syminfo.ticker == "SXXP"
    V := 2.5 * EUM0 / 100000000000
if syminfo.ticker == "SX5E" or syminfo.ticker == "CAC40"
    V := 2.5 * EUM0 / 10000000000
if syminfo.ticker == "DAX"
    V := 5 * EUM0 / 10000000000
if syminfo.ticker == "FTSE100" or syminfo.ticker == "UK100"
    V := 2.5 * GBM0 / 100000000
if syminfo.ticker == "000001"
    V := 1 * CNM0 / 10000000000
if syminfo.ticker == "399001"
    V := 2.5 * CNM0 / 10000000000
if syminfo.ticker == "NKY" or syminfo.ticker == "NI225"
    V := 7.5 * JPM0 / 100000000000
if syminfo.ticker == "HSI"
    V := 2.5 * HKM0 / 100000000
if syminfo.ticker == "STI"
    V := 2.5 * SGM0 / 100000000
if syminfo.ticker=="TSX"
    V := 2.5 * CAM0 / 100000000
if syminfo.ticker=="ASX200" or syminfo.ticker == "AUS200"
    V := 7.5 * AUM0 / 1000000000
if syminfo.ticker=="COMPOSITE"
    V := 2.5 * IDM0 / 1000000000000
Vx10 = 10 * V
Vx9 = 9 * V
Vx8 = 8 * V
Vx7 = 7 * V
Vx6 = 6 * V
Vx5 = 5 * V
Vx4 = 4 * V
Vx3 = 3 * V
Vx2 = 2 * V
p1=plot(Vx10, "Vx10", color.rgb(133, 39, 176, 60))
p2=plot(Vx9, "Vx9", color.rgb(155, 39, 176, 60))
p3=plot(Vx8, "Vx8", color.rgb(223, 64, 251, 60))
p4=plot(Vx7, "Vx7", color.rgb(255, 82, 82, 60))
p5=plot(Vx6, "Vx6", color.rgb(255, 153, 0, 60))
p6=plot(Vx5, "Vx5", color.rgb(255, 235, 59, 60))
p7=plot(Vx4, "Vx4", color.rgb(0, 230, 119, 60))
p8=plot(Vx3, "Vx3", color.rgb(0, 187, 212, 60))
p9=plot(Vx2, "Vx2", color.rgb(33, 149, 243, 60))
p10=plot(V, "Vx0.8", color.rgb(120, 123, 134, 0), 2)
fill(p1, p2, top_value = Vx10, bottom_value = Vx9, top_color = color.rgb(133, 39, 176, 60), bottom_color = color.rgb(155, 39, 176, 60))
fill(p2, p3, top_value = Vx9, bottom_value = Vx8, top_color = color.rgb(155, 39, 176, 60), bottom_color = color.rgb(223, 64, 251, 80))
fill(p3, p4, top_value = Vx8, bottom_value = Vx7, top_color = color.rgb(223, 64, 251, 80), bottom_color = color.rgb(255, 82, 82, 80))
fill(p4, p5, top_value = Vx7, bottom_value = Vx6, top_color = color.rgb(255, 82, 82, 80), bottom_color = color.rgb(255, 153, 0, 80))
fill(p5, p6, top_value = Vx6, bottom_value = Vx5, top_color = color.rgb(255, 153, 0, 80), bottom_color = color.rgb(255, 235, 59, 80))
fill(p6, p7, top_value = Vx5, bottom_value = Vx4, top_color = color.rgb(255, 235, 59, 80), bottom_color = color.rgb(0, 230, 119, 80))
fill(p7, p8, top_value = Vx4, bottom_value = Vx3, top_color = color.rgb(0, 230, 119, 80), bottom_color = color.rgb(0, 187, 212, 80))
fill(p8, p9, top_value = Vx3, bottom_value = Vx2, top_color = color.rgb(0, 187, 212, 80), bottom_color = color.rgb(33, 149, 243, 80))
fill(p9, p10, top_value = Vx2, bottom_value = V, top_color = color.rgb(33, 149, 243, 80), bottom_color = color.rgb(120, 123, 134, 60))
