Enterprise Value on Earnings / FCF / FFO Band 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Nagumo_Tetora
//Per Share Enterprise Value Superimposed onto Free Cash Flow / Operating Income (Earnings) / Adjusted Funds from Operations Rainbow Band
//@version=5
indicator("EV Band", overlay = true)
NetDebt = request.financial(syminfo.tickerid, "TOTAL_DEBT", "FY") - request.financial(syminfo.tickerid, "CASH_N_EQUIVALENTS", "FY")
DilutedSharesOutstanding = request.financial(syminfo.tickerid, "DILUTED_SHARES_OUTSTANDING", "FQ")
NDpS = NetDebt / DilutedSharesOutstanding //Net Debt per Share
EVpS = NDpS + close //Enterprise Value per Share

FreeCashFlow = request.financial(syminfo.tickerid, "FREE_CASH_FLOW", "FY")
OperatingIncome = request.financial(syminfo.tickerid, "OPER_INCOME", "FY")
OperatingCashflow = request.financial(syminfo.tickerid, "CASH_F_OPERATING_ACTIVITIES","FY")
AdjustedFundsfromOperations = request.financial(syminfo.tickerid, "FUNDS_F_OPERATIONS", "FY") - request.financial(syminfo.tickerid, "UNUSUAL_EXPENSE_INC", "FY") * (1 - 0.25)
CoreEarnings = request.financial(syminfo.tickerid, "NET_INCOME", "FY") - request.financial(syminfo.tickerid, "UNUSUAL_EXPENSE_INC", "FY") * (1 - 0.25)

FCFpS = FreeCashFlow / DilutedSharesOutstanding //Free Cash Flow per Share
OIpS = OperatingIncome / DilutedSharesOutstanding //Operating Income per Share
OFpS = OperatingCashflow /DilutedSharesOutstanding //Cashflow from Operations per Share
AFfOpS = AdjustedFundsfromOperations / DilutedSharesOutstanding  //Adjusted Funds from Operations per Share
CEpS = CoreEarnings / DilutedSharesOutstanding //Core Earnings per Share

//Plot
plot(EVpS, linewidth  = 3, color = color.black)

string i_icType = input.string("Free Cash Flow", "Band Type", options = ["Free Cash Flow", "Operating Income", "Cashflow from Operations", "Adjusted Funds from Operations", "Core Earnings"])

float BandMetric = switch i_icType
    "Free Cash Flow" => FCFpS 
    "Operating Income" => OIpS
    "Cashflow from Operations" => OFpS
    "Adjusted Funds from Operations" => AFfOpS
    "Core Earnings" => CEpS

BandMetric_00 = BandMetric * 5
BandMetric_01 = BandMetric * 10
BandMetric_02 = BandMetric * 15
BandMetric_03 = BandMetric * 20
BandMetric_04 = BandMetric * 25
BandMetric_05 = BandMetric * 30
Band_00 = plot(BandMetric_00, linewidth  = 1, color = color.rgb(129, 129, 129, 33))
Band_01 = plot(BandMetric_01, linewidth  = 1, color = color.rgb(129, 129, 129, 33))
Band_02 = plot(BandMetric_02, linewidth  = 1, color = color.rgb(129, 129, 129, 33))
Band_03 = plot(BandMetric_03, linewidth  = 1, color = color.rgb(129, 129, 129, 33))
Band_04 = plot(BandMetric_04, linewidth  = 1, color = color.rgb(129, 129, 129, 33))
Band_05 = plot(BandMetric_05, linewidth  = 1, color = color.rgb(129, 129, 129, 33))

fill(Band_00,Band_01,BandMetric_01,BandMetric_00,color.rgb(255, 0, 0, 33),color.rgb(128, 0, 255, 33))
fill(Band_01,Band_02,BandMetric_02,BandMetric_01,color.rgb(255, 255, 0, 33),color.rgb(255, 0, 0, 33))
fill(Band_02,Band_03,BandMetric_03,BandMetric_02,color.rgb(0, 255, 0, 33),color.rgb(255, 255, 0, 33))
fill(Band_03,Band_04,BandMetric_04,BandMetric_03,color.rgb(0, 255, 255, 33),color.rgb(0, 255, 0, 33))
fill(Band_04,Band_05,BandMetric_05,BandMetric_04,color.rgb(255, 255, 255),color.rgb(0, 255, 255, 33))