Indicator · Pine Script v5 · Own pane

CE - 42MACRO Equity Factor Table

by regalouisei· code credited to Celestial-Eye

This indicator draws an equity factor dashboard in a separate pane.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code571
Settings25inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago25 Feb 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

571 lines of Pine Script v5 from pinescript/editors_picks/ce-42macro-equity-factor-table.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

ce-42macro-equity-factor-table.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Celestial-Eye

//@version=5
indicator("🌌 CE - 42MACRO Equity Factor Table 🌌", "🌌 CE - EFT 🌌")

showCorrTab = input.bool(true,  "Show Correlation Table",   tooltip = "Plots the Correlation table",                        group = "🌌 Table Settings Correlation 🌌")
l           = input.int (14,    "Correlation Length",       tooltip = "Defines the time horizon for the Correlation Table", group = "🌌 Table Settings Correlation 🌌")

showPerfTab = input.bool(true,  "Show Performance Table",   tooltip = "Plots the Performance table",                        group = "🌌 Table Settings Performance 🌌")
rocPeriod   = input.int (14,    "RoC Period", minval=1,     tooltip = "Defines the time horizon for the Equity Table",      group = "🌌 Table Settings Performance 🌌")
useSharpe   = input.bool(false, "Use Sharpe instead of Rate of Change",                                                     group = "🌌 Table Settings Performance 🌌")

showImplied       = input.bool(false, "Show Implied Correlation?",                  tooltip = "Shows Implied Correlation on Chart, disable all other Visuals for best Experience",                                  group = "Implied Correlation - ONLY ENABLE A SINGLE IMPLIED CORRELATION OPTION")
showImpliedNorm   = input.bool(false, "Show Normalized Implied Correlation?",       tooltip = "Better for Crypto... As Crypto Moves faster",                                                                        group = "Implied Correlation - ONLY ENABLE A SINGLE IMPLIED CORRELATION OPTION")
norm_periodImpl   = input.int (50,    "Normalization lookback",     minval=1,       tooltip = "Defines the time horizon for the Normalization - 40 to 70 is a good start",                                          group = "Implied Correlation - ONLY ENABLE A SINGLE IMPLIED CORRELATION OPTION")
showImpliedNorm2  = input.bool(false, "Show double Normalized Implied Correlation?",tooltip = "Even better for Crypto... As Crypto Moves faster",                                                                   group = "Implied Correlation - ONLY ENABLE A SINGLE IMPLIED CORRELATION OPTION")
norm_periodImpl2  = input.int (40,    "Second Normalization lookback",   minval=1,  tooltip = "Defines the time horizon for the second Normalization - usually 10 - 20 less than first Normalization is best",      group = "Implied Correlation - ONLY ENABLE A SINGLE IMPLIED CORRELATION OPTION")

useMA             = input.bool(true,  "Overlay HMA for slightly earlier signals?",                                                                                                          group = "HMA for Implied Correlation")
MALen             = input.int (3,     "Lenght of HMA",                                                                                                                                      group = "HMA for Implied Correlation")
HMASigCol         = input.bool(false, "Background Coloring for HMA Signals",        tooltip = "Uses HMA to give signals, might be earlier but contain some false positives",                group = "HMA for Implied Correlation")

implBarCol        = input.bool(false, "Barcoloring for Impl. Correlation?",         tooltip = "Barcoloring for chosen Implied Correlation",                                                 group = "Visuals")
reg               = input.bool(false, "Show approximate Macroeconomic GRID Regimes",                                                                                                        group = "Visuals")
col               = input.bool(false, "Show Risk On - Risk Off periods",            tooltip = "Works better with higher timeframes/RoC Periods; Macro data takes a while to be realized",   group = "Visuals")

//request securities
VO   = request.security("VO",   "D", close, barmerge.gaps_off)
SPHD = request.security("SPHD", "D", close, barmerge.gaps_off)
EEM  = request.security("EEM",  "D", close, barmerge.gaps_off)
DXJ  = request.security("DXJ",  "D", close, barmerge.gaps_off)
QQQ  = request.security("QQQ",  "D", close, barmerge.gaps_off)
EWZ  = request.security("EWZ",  "D", close, barmerge.gaps_off)
EWU  = request.security("EWU",  "D", close, barmerge.gaps_off)
IWF  = request.security("IWF",  "D", close, barmerge.gaps_off)
SPY  = request.security("SPY",  "D", close, barmerge.gaps_off)
INDA = request.security("INDA", "D", close, barmerge.gaps_off)
FXI  = request.security("FXI",  "D", close, barmerge.gaps_off)
SPLV = request.security("SPLV", "D", close, barmerge.gaps_off)
ACWX = request.security("ACWX", "D", close, barmerge.gaps_off)
EZU  = request.security("EZU",  "D", close, barmerge.gaps_off)
QUAL = request.security("QUAL", "D", close, barmerge.gaps_off)
SPHB = request.security("SPHB", "D", close, barmerge.gaps_off)
MTUM = request.security("MTUM", "D", close, barmerge.gaps_off)
OEF  = request.security("OEF",  "D", close, barmerge.gaps_off)
IWM  = request.security("IWM",  "D", close, barmerge.gaps_off)



//calculate the average RoC
avgROC = (ta.roc(VO,  rocPeriod) +
         ta.roc(SPHD, rocPeriod) +
         ta.roc(EEM,  rocPeriod) +
         ta.roc(DXJ,  rocPeriod) +
         ta.roc(QQQ,  rocPeriod) +
         ta.roc(EWZ,  rocPeriod) +
         ta.roc(EWU,  rocPeriod) +
         ta.roc(IWF,  rocPeriod) +
         ta.roc(SPY,  rocPeriod) +
         ta.roc(INDA, rocPeriod) +
         ta.roc(FXI,  rocPeriod) +
         ta.roc(ACWX, rocPeriod) +
         ta.roc(EZU,  rocPeriod) +
         ta.roc(QUAL, rocPeriod) +
         ta.roc(SPHB, rocPeriod) +
         ta.roc(SPLV, rocPeriod) +
         ta.roc(OEF,  rocPeriod) +
         ta.roc(IWM,  rocPeriod) +
         ta.roc(MTUM, rocPeriod)) / 19

//function to calculate Sharpe Ratio
f_sharpe(src, lookback) =>
    float daily_return = src / src[1] - 1
    returns_array = array.new_float(0)
    for i = 0 to lookback
        array.push(returns_array, daily_return[i])
    
    standard_deviation = array.stdev(returns_array)
    mean = array.avg(returns_array)
    
    math.round(mean / standard_deviation * math.sqrt(lookback), 2)


var float rocVO   = na
var float rocSPHD = na
var float rocEEM  = na
var float rocDXJ  = na 
var float rocQQQ  = na 
var float rocEWZ  = na 
var float rocEWU  = na 
var float rocIWF  = na 
var float rocSPY  = na
var float rocINDA = na
var float rocFXI  = na 
var float rocSPLV = na
var float rocACWX = na
var float rocEZU  = na
var float rocQUAL = na
var float rocSPHB = na
var float rocMTUM = na
var float rocIWM  = na
var float rocOEF  = na



if useSharpe == false
    // Calculate the relative RoC for each asset - Standard
    rocVO   := ta.roc(VO,   rocPeriod) - avgROC
    rocSPHD := ta.roc(SPHD, rocPeriod) - avgROC
    rocEEM  := ta.roc(EEM,  rocPeriod) - avgROC
    rocDXJ  := ta.roc(DXJ,  rocPeriod) - avgROC
    rocQQQ  := ta.roc(QQQ,  rocPeriod) - avgROC
    rocEWZ  := ta.roc(EWZ,  rocPeriod) - avgROC
    rocEWU  := ta.roc(EWU,  rocPeriod) - avgROC
    rocIWF  := ta.roc(IWF,  rocPeriod) - avgROC
    rocSPY  := ta.roc(SPY,  rocPeriod) - avgROC
    rocINDA := ta.roc(INDA, rocPeriod) - avgROC
    rocFXI  := ta.roc(FXI,  rocPeriod) - avgROC
    rocSPLV := ta.roc(SPLV, rocPeriod) - avgROC
    rocACWX := ta.roc(ACWX, rocPeriod) - avgROC
    rocEZU  := ta.roc(EZU,  rocPeriod) - avgROC
    rocQUAL := ta.roc(QUAL, rocPeriod) - avgROC
    rocSPHB := ta.roc(SPHB, rocPeriod) - avgROC
    rocMTUM := ta.roc(MTUM, rocPeriod) - avgROC
    rocIWM  := ta.roc(IWM,  rocPeriod) - avgROC
    rocOEF  := ta.roc(OEF,  rocPeriod) - avgROC
    
else if useSharpe == true
    // Calculate the Sharpe ratio for each asset - Optional
    rocVO   := f_sharpe(VO,   rocPeriod)
    rocSPHD := f_sharpe(SPHD, rocPeriod)
    rocEEM  := f_sharpe(EEM,  rocPeriod)
    rocDXJ  := f_sharpe(DXJ,  rocPeriod)
    rocQQQ  := f_sharpe(QQQ,  rocPeriod)
    rocEWZ  := f_sharpe(EWZ,  rocPeriod)
    rocEWU  := f_sharpe(EWU,  rocPeriod)
    rocIWF  := f_sharpe(IWF,  rocPeriod)
    rocSPY  := f_sharpe(SPY,  rocPeriod)
    rocINDA := f_sharpe(INDA, rocPeriod)
    rocFXI  := f_sharpe(FXI,  rocPeriod)
    rocSPLV := f_sharpe(SPLV, rocPeriod)
    rocACWX := f_sharpe(ACWX, rocPeriod)
    rocEZU  := f_sharpe(EZU,  rocPeriod)
    rocQUAL := f_sharpe(QUAL, rocPeriod)
    rocSPHB := f_sharpe(SPHB, rocPeriod)
    rocMTUM := f_sharpe(MTUM, rocPeriod)
    rocIWM  := f_sharpe(IWM,  rocPeriod)
    rocOEF  := f_sharpe(OEF,  rocPeriod)

//calculate the correlation for each asset
correlation_VO   = ta.correlation(close, VO,   l)
correlation_SPHD = ta.correlation(close, SPHD, l)
correlation_EEM  = ta.correlation(close, EEM,  l)
correlation_DXJ  = ta.correlation(close, DXJ,  l)
correlation_QQQ  = ta.correlation(close, QQQ,  l)
correlation_EWZ  = ta.correlation(close, EWZ,  l)
correlation_EWU  = ta.correlation(close, EWU,  l)
correlation_IWF  = ta.correlation(close, IWF,  l)
correlation_SPY  = ta.correlation(close, SPY,  l)
correlation_INDA = ta.correlation(close, INDA, l)
correlation_FXI  = ta.correlation(close, FXI,  l)
correlation_SPLV = ta.correlation(close, SPLV, l)
correlation_ACWX = ta.correlation(close, ACWX, l)
correlation_EZU  = ta.correlation(close, EZU,  l)
correlation_QUAL = ta.correlation(close, QUAL, l)
correlation_SPHB = ta.correlation(close, SPHB, l)
correlation_MTUM = ta.correlation(close, MTUM, l)
correlation_IWM  = ta.correlation(close, IWM,  l)
correlation_OEF  = ta.correlation(close, OEF,  l)

//Calculate Trend Value for each Asset with Normalized KAMA Oscillator by IKKE OMAR
// -> https://www.tradingview.com/script/OwtiIzT3-Normalized-KAMA-Oscillator-Ikke-Omar/
// For best performance use this Indicator on the underlying Assets and adjust the Normalization lookback to the moves you want to capture
kama(asset) =>
    // Define input parameters
    fast_period = input.int(title='Fast Period',             defval=7,  minval=1, group = "Norm KAMA", tooltip = "Normalized KAMA Oscillator by IkkeOmar")
    slow_period = input.int(title='Slow Period',             defval=19, minval=1, group = "Norm KAMA")
    er_period   = input.int(title='Efficiency Ratio Period', defval=8,  minval=1, group = "Norm KAMA")
    norm_period = input.int(title='Normalization lookback',  defval=10, minval=1, group = "Norm KAMA", tooltip = "Defines the time horizon for the Trend calculation of the ETF's - For longer term Trends over weeks or months a length of 50 is usually pretty accurate")

    // Calculate the efficiency ratio
    change     = math.abs(asset - asset[er_period])
    volatility = math.sum(math.abs(asset - asset[1]), er_period)
    er         = change / volatility

    // Calculate the smoothing constant
    sc = er * (2 / (fast_period + 1) - 2 / (slow_period + 1)) + 2 / (slow_period + 1)

    // Calculate the KAMA
    kama = ta.ema(asset, fast_period) + sc * (asset - ta.ema(asset, fast_period))

    // Normalize the Oscillator
    lowest  = ta.lowest (kama, norm_period)
    highest = ta.highest(kama, norm_period)
    normalized = (kama - lowest) / (highest - lowest) - 0.5
    normalized

//Calculate trend for assets 
kamaVO   = kama(VO)   > 0? 1 : -1 
kamaSPHD = kama(SPHD) > 0? 1 : -1 
kamaEEM  = kama(EEM)  > 0? 1 : -1 
kamaDXJ  = kama(DXJ)  > 0? 1 : -1 
kamaQQQ  = kama(QQQ)  > 0? 1 : -1 
kamaEWZ  = kama(EWZ)  > 0? 1 : -1 
kamaEWU  = kama(EWU)  > 0? 1 : -1 
kamaIWF  = kama(IWF)  > 0? 1 : -1 
kamaSPY  = kama(SPY)  > 0? 1 : -1 
kamaINDA = kama(INDA) > 0? 1 : -1 
kamaFXI  = kama(FXI)  > 0? 1 : -1 
kamaSPLV = kama(SPLV) > 0? 1 : -1 
kamaACWX = kama(ACWX) > 0? 1 : -1 
kamaEZU  = kama(EZU)  > 0? 1 : -1 
kamaQUAL = kama(QUAL) > 0? 1 : -1 
kamaSPHB = kama(SPHB) > 0? 1 : -1 
kamaMTUM = kama(MTUM) > 0? 1 : -1 
kamaIWM  = kama(IWM)  > 0? 1 : -1 
kamaOEF  = kama(OEF)  > 0? 1 : -1 


//Calculate Average Implied Correlation 
ImplCorrAvg = math.avg(
     math.round(correlation_VO*      kamaVO,   2), 
     math.round(correlation_SPHD*    kamaSPHD, 2), 
     math.round(correlation_EEM*     kamaEEM,  2), 
     math.round(correlation_DXJ*     kamaDXJ,  2), 
     math.round(correlation_QQQ*     kamaQQQ,  2), 
     math.round(correlation_EWZ*     kamaEWZ,  2), 
     math.round(correlation_EWU*     kamaEWU,  2), 
     math.round(correlation_IWF*     kamaIWF,  2), 
     math.round(correlation_SPY*     kamaSPY,  2),  
     math.round(correlation_INDA*    kamaINDA, 2), 
     math.round(correlation_FXI*     kamaFXI,  2), 
     math.round(correlation_SPLV*    kamaSPLV, 2), 
     math.round(correlation_ACWX*    kamaACWX, 2), 
     math.round(correlation_EZU*     kamaEZU,  2), 
     math.round(correlation_QUAL*    kamaQUAL, 2), 
     math.round(correlation_SPHB*    kamaSPHB, 2),
     math.round(correlation_IWM*     kamaIWM,  2),
     math.round(correlation_OEF*     kamaOEF,  2),
     math.round(correlation_MTUM*    kamaMTUM, 2)) 


// Display correlation values
var string G3 = "🌌 Table Settings Correlation 🌌"

string table0_y_pos = input.string(defval = "top",    title = "Table Position", options = ["top", "middle", "bottom"],                                          group = G3, inline = "1")
string table0_x_pos = input.string(defval = "right",  title = "",               options = ["left", "center", "right"],                                          group = G3, inline = "1")
string i_text_size  = input.string(defval = size.tiny,title='Text Size:',       options=[size.tiny, size.small, size.normal, size.large, size.huge, size.auto], group = G3              )

var table table0 = table.new(
     table0_y_pos + "_" + table0_x_pos, 
     columns = 20, rows = 6, frame_color = color.white,
     frame_width = 1,
     border_color = color.white, 
     border_width = 1)

if showCorrTab
    table.merge_cells(table0, 0, 0, 19, 0)
    table.merge_cells(table0, 0, 4, 19, 4)

if showCorrTab and barstate.islast
    table.cell(table0, 0, 0, "🌌 CE - EQUITY FACTOR CORRELATION "+str.tostring(l)+"D 🌌", text_size = i_text_size, text_color = color.purple)
    table.cell(table0, 0, 1, "Symbol:",                                               text_size = i_text_size, text_color = color.white, bgcolor = color.black)
    table.cell(table0, 0, 2, "Correlation:",                                          text_size = i_text_size, text_color = color.white, bgcolor = color.black)
    table.cell(table0, 0, 3, "Trend:",                                                text_size = i_text_size, text_color = color.white, bgcolor = color.black)
    table.cell(table0, 0, 4, "Implied Trend to Chart "+str.tostring(l)+"D :",         text_size = i_text_size, text_color = color.white, bgcolor = color.black)
    table.cell(table0, 0, 5, "Avg: " + str.tostring(math.round(ImplCorrAvg,2)),       text_size = i_text_size, text_color = math.round(ImplCorrAvg,2) > 0 ?color.green:color.red)

    table.cell(table0, 1, 1, "VO", text_size = i_text_size, text_color = color.teal)
    table.cell(table0, 1, 2, str.tostring(math.round(correlation_VO, 2)),             text_size = i_text_size, text_color = correlation_VO      > 0 ? color.green : color.red)
    table.cell(table0, 1, 3, str.tostring(kamaVO),                                    text_size = i_text_size, text_color = kamaVO              > 0 ? color.green : color.red)
    table.cell(table0, 1, 5, str.tostring(math.round(correlation_VO*kamaVO, 2)),      text_size = i_text_size, text_color = math.round(correlation_VO*kamaVO, 2) > 0 ? color.green : color.red)

    table.cell(table0, 2, 1, "SPHD", text_size = i_text_size, text_color = color.aqua)
    table.cell(table0, 2, 2, str.tostring(math.round(correlation_SPHD, 2)),           text_size = i_text_size, text_color = correlation_SPHD    > 0 ? color.green : color.red)
    table.cell(table0, 2, 3, str.tostring(kamaSPHD),                                  text_size = i_text_size, text_color = kamaSPHD            > 0 ? color.green : color.red)
    table.cell(table0, 2, 5, str.tostring(math.round(correlation_SPHD*kamaSPHD, 2)),  text_size = i_text_size, text_color = math.round(correlation_SPHD*kamaSPHD, 2) > 0 ? color.green : color.red)

    table.cell(table0, 3, 1, "EEM", text_size = i_text_size, text_color = color.gray)
    table.cell(table0, 3, 2, str.tostring(math.round(correlation_EEM, 2)),            text_size = i_text_size, text_color = correlation_EEM     > 0 ? color.green : color.red)
    table.cell(table0, 3, 3, str.tostring(kamaEEM),                                   text_size = i_text_size, text_color = kamaEEM             > 0 ? color.green : color.red)
    table.cell(table0, 3, 5, str.tostring(math.round(correlation_EEM*kamaEEM, 2)),    text_size = i_text_size, text_color = math.round(correlation_EEM*kamaEEM, 2) > 0 ? color.green : color.red)

    table.cell(table0, 4, 1, "QUAL", text_size = i_text_size, text_color = color.maroon)
    table.cell(table0, 4, 2, str.tostring(math.round(correlation_QUAL, 2)),           text_size = i_text_size, text_color = correlation_QUAL    > 0 ? color.green : color.red)
    table.cell(table0, 4, 3, str.tostring(kamaQUAL),                                  text_size = i_text_size, text_color = kamaQUAL            > 0 ? color.green : color.red)
    table.cell(table0, 4, 5, str.tostring(math.round(correlation_QUAL*kamaQUAL, 2)),  text_size = i_text_size, text_color = math.round(correlation_QUAL*kamaQUAL, 2) > 0 ? color.green : color.red)

    table.cell(table0, 5, 1, "QQQ", text_size = i_text_size, text_color = color.orange)
    table.cell(table0, 5, 2, str.tostring(math.round(correlation_QQQ, 2)),            text_size = i_text_size, text_color = correlation_QQQ     > 0 ? color.green : color.red)
    table.cell(table0, 5, 3, str.tostring(kamaQQQ),                                   text_size = i_text_size, text_color = kamaQQQ             > 0 ? color.green : color.red)
    table.cell(table0, 5, 5, str.tostring(math.round(correlation_QQQ*kamaQQQ, 2)),    text_size = i_text_size, text_color = math.round(correlation_QQQ*kamaQQQ, 2) > 0 ? color.green : color.red)

    table.cell(table0, 6, 1, "EWZ", text_size = i_text_size, text_color = color.rgb(239, 136, 227))
    table.cell(table0, 6, 2, str.tostring(math.round(correlation_EWZ, 2)),            text_size = i_text_size, text_color = correlation_EWZ     > 0 ? color.green : color.red)
    table.cell(table0, 6, 3, str.tostring(kamaEWZ),                                   text_size = i_text_size, text_color = kamaEWZ             > 0 ? color.green : color.red)
    table.cell(table0, 6, 5, str.tostring(math.round(correlation_EWZ*kamaEWZ, 2)),    text_size = i_text_size, text_color = math.round(correlation_EWZ*kamaEWZ, 2) > 0 ? color.green : color.red)

    table.cell(table0, 7, 1, "EWU", text_size = i_text_size, text_color = color.yellow)
    table.cell(table0, 7, 2, str.tostring(math.round(correlation_EWU, 2)),            text_size = i_text_size, text_color = correlation_EWU     > 0 ? color.green : color.red)
    table.cell(table0, 7, 3, str.tostring(kamaEWU),                                   text_size = i_text_size, text_color = kamaEWU             > 0 ? color.green : color.red)
    table.cell(table0, 7, 5, str.tostring(math.round(correlation_EWU*kamaEWU, 2)),    text_size = i_text_size, text_color = math.round(correlation_EWU*kamaEWU, 2) > 0 ? color.green : color.red)

    table.cell(table0, 8, 1, "IWF", text_size = i_text_size, text_color = color.yellow)
    table.cell(table0, 8, 2, str.tostring(math.round(correlation_IWF, 2)),            text_size = i_text_size, text_color = correlation_IWF     > 0 ? color.green : color.red)
    table.cell(table0, 8, 3, str.tostring(kamaIWF),                                   text_size = i_text_size, text_color = kamaIWF             > 0 ? color.green : color.red)
    table.cell(table0, 8, 5, str.tostring(math.round(correlation_IWF*kamaIWF, 2)),    text_size = i_text_size, text_color = math.round(correlation_IWF*kamaIWF, 2) > 0 ? color.green : color.red)

    table.cell(table0, 9, 1, "SPY", text_size = i_text_size, text_color = color.fuchsia)
    table.cell(table0, 9, 2, str.tostring(math.round(correlation_SPY, 2)),            text_size = i_text_size, text_color = correlation_SPY     > 0 ? color.green : color.red)
    table.cell(table0, 9, 3, str.tostring(kamaSPY),                                   text_size = i_text_size, text_color = kamaSPY             > 0 ? color.green : color.red)
    table.cell(table0, 9, 5, str.tostring(math.round(correlation_SPY*kamaSPY, 2)),    text_size = i_text_size, text_color = math.round(correlation_SPY*kamaSPY, 2) > 0 ? color.green : color.red)

    table.cell(table0, 10, 1, "DXJ", text_size = i_text_size, text_color = color.purple)
    table.cell(table0, 10, 2, str.tostring(math.round(correlation_DXJ, 2)),           text_size = i_text_size, text_color = correlation_DXJ     > 0 ? color.green : color.red)
    table.cell(table0, 10, 3, str.tostring(kamaDXJ),                                  text_size = i_text_size, text_color = kamaDXJ             > 0 ? color.green : color.red)
    table.cell(table0, 10, 5, str.tostring(math.round(correlation_DXJ*kamaDXJ, 2)),   text_size = i_text_size, text_color = math.round(correlation_DXJ*kamaDXJ, 2) > 0 ? color.green : color.red)

    table.cell(table0, 11, 1, "INDA", text_size = i_text_size, text_color = color.blue)
    table.cell(table0, 11, 2, str.tostring(math.round(correlation_INDA, 2)),          text_size = i_text_size, text_color = correlation_INDA    > 0 ? color.green : color.red)
    table.cell(table0, 11, 3, str.tostring(kamaINDA),                                 text_size = i_text_size, text_color = kamaINDA            > 0 ? color.green : color.red)
    table.cell(table0, 11, 5, str.tostring(math.round(correlation_INDA*kamaINDA, 2)), text_size = i_text_size, text_color = math.round(correlation_INDA*kamaINDA, 2) > 0 ? color.green : color.red)

    table.cell(table0, 12, 1, "FXI", text_size = i_text_size, text_color = color.red)
    table.cell(table0, 12, 2, str.tostring(math.round(correlation_FXI, 2)),           text_size = i_text_size, text_color = correlation_FXI     > 0 ? color.green : color.red)
    table.cell(table0, 12, 3, str.tostring(kamaFXI),                                  text_size = i_text_size, text_color = kamaFXI             > 0 ? color.green : color.red)
    table.cell(table0, 12, 5, str.tostring(math.round(correlation_FXI*kamaFXI, 2)),   text_size = i_text_size, text_color = math.round(correlation_FXI*kamaFXI, 2) > 0 ? color.green : color.red)

    table.cell(table0, 13, 1, "SPLV", text_size = i_text_size, text_color = color.olive)
    table.cell(table0, 13, 2, str.tostring(math.round(correlation_SPLV, 2)),          text_size = i_text_size, text_color = correlation_SPLV    > 0 ? color.green : color.red)
    table.cell(table0, 13, 3, str.tostring(kamaSPLV),                                 text_size = i_text_size, text_color = kamaSPLV            > 0 ? color.green : color.red)
    table.cell(table0, 13, 5, str.tostring(math.round(correlation_SPLV*kamaSPLV, 2)), text_size = i_text_size, text_color = math.round(correlation_SPLV*kamaSPLV, 2) > 0 ? color.green : color.red)

    table.cell(table0, 14, 1, "EZU", text_size = i_text_size, text_color = color.lime)
    table.cell(table0, 14, 2, str.tostring(math.round(correlation_EZU, 2)),           text_size = i_text_size, text_color = correlation_EZU     > 0 ? color.green : color.red)
    table.cell(table0, 14, 3, str.tostring(kamaEZU),                                  text_size = i_text_size, text_color = kamaEZU             > 0 ? color.green : color.red)
    table.cell(table0, 14, 5, str.tostring(math.round(correlation_EZU*kamaEZU, 2)),   text_size = i_text_size, text_color = math.round(correlation_EZU*kamaEZU, 2) > 0 ? color.green : color.red)

    table.cell(table0, 15, 1, "ACWX", text_size = i_text_size, text_color = color.silver)
    table.cell(table0, 15, 2, str.tostring(math.round(correlation_ACWX, 2)),          text_size = i_text_size, text_color = correlation_ACWX    > 0 ? color.green : color.red)
    table.cell(table0, 15, 3, str.tostring(kamaACWX),                                 text_size = i_text_size, text_color = kamaACWX            > 0 ? color.green : color.red)
    table.cell(table0, 15, 5, str.tostring(math.round(correlation_ACWX*kamaACWX, 2)), text_size = i_text_size, text_color = math.round(correlation_ACWX*kamaACWX, 2) > 0 ? color.green : color.red)

    table.cell(table0, 16, 1, "SPHB", text_size = i_text_size, text_color = color.silver)
    table.cell(table0, 16, 2, str.tostring(math.round(correlation_SPHB, 2)),          text_size = i_text_size, text_color = correlation_SPHB    > 0 ? color.green : color.red)
    table.cell(table0, 16, 3, str.tostring(kamaSPHB),                                 text_size = i_text_size, text_color = kamaSPHB            > 0 ? color.green : color.red)
    table.cell(table0, 16, 5, str.tostring(math.round(correlation_SPHB*kamaSPHB, 2)), text_size = i_text_size, text_color = math.round(correlation_SPHB*kamaSPHB, 2) > 0 ? color.green : color.red)

    table.cell(table0, 17, 1, "MTUM", text_size = i_text_size, text_color = color.silver)
    table.cell(table0, 17, 2, str.tostring(math.round(correlation_MTUM, 2)),          text_size = i_text_size, text_color = correlation_MTUM    > 0 ? color.green : color.red)
    table.cell(table0, 17, 3, str.tostring(kamaMTUM),                                 text_size = i_text_size, text_color = kamaMTUM            > 0 ? color.green : color.red)
    table.cell(table0, 17, 5, str.tostring(math.round(correlation_MTUM*kamaMTUM, 2)), text_size = i_text_size, text_color = math.round(correlation_MTUM*kamaMTUM, 2) > 0 ? color.green : color.red)
    
    table.cell(table0, 18, 1, "IWM", text_size = i_text_size, text_color = color.silver)
    table.cell(table0, 18, 2, str.tostring(math.round(correlation_IWM, 2)),          text_size = i_text_size, text_color = correlation_IWM    > 0 ? color.green : color.red)
    table.cell(table0, 18, 3, str.tostring(kamaIWM),                                 text_size = i_text_size, text_color = kamaIWM            > 0 ? color.green : color.red)
    table.cell(table0, 18, 5, str.tostring(math.round(correlation_IWM*kamaIWM, 2)),  text_size = i_text_size, text_color = math.round(correlation_IWM*kamaIWM, 2) > 0 ? color.green : color.red)

    table.cell(table0, 19, 1, "OEF", text_size = i_text_size, text_color = color.silver)
    table.cell(table0, 19, 2, str.tostring(math.round(correlation_OEF, 2)),          text_size = i_text_size, text_color = correlation_OEF    > 0 ? color.green : color.red)
    table.cell(table0, 19, 3, str.tostring(kamaOEF),                                 text_size = i_text_size, text_color = kamaOEF            > 0 ? color.green : color.red)
    table.cell(table0, 19, 5, str.tostring(math.round(correlation_OEF*kamaOEF, 2)),  text_size = i_text_size, text_color = math.round(correlation_OEF*kamaOEF, 2) > 0 ? color.green : color.red)

// Implied Correlation Normalization
lowest  = ta.lowest (ImplCorrAvg, norm_periodImpl)
highest = ta.highest(ImplCorrAvg, norm_periodImpl)
ImplCorrAvgNorm = (ImplCorrAvg - lowest) / (highest - lowest) - 0.5

lowest2  = ta.lowest (ImplCorrAvgNorm, norm_periodImpl2)
highest2 = ta.highest(ImplCorrAvgNorm, norm_periodImpl2)
ImplCorrAvgNormDouble = (ImplCorrAvgNorm - lowest2) / (highest2 - lowest2) - 0.5

// Implied Correlation Visuals
plot(showImplied?       ImplCorrAvg:na,           "Implied Correlation Avg",                   ImplCorrAvg > 0.1            ?color.green : ImplCorrAvg           < -0.1 ? color.red : color.gray, style = plot.style_columns)
plot(showImpliedNorm?   ImplCorrAvgNorm:na,       "Implied Correlation Avg Normalized",        ImplCorrAvgNorm > 0.1        ?color.green : ImplCorrAvgNorm       < -0.1 ? color.red : color.gray, style = plot.style_columns)
plot(showImpliedNorm2?  ImplCorrAvgNormDouble:na, "Implied Correlation Avg double Normalized", ImplCorrAvgNormDouble > 0.1  ?color.green : ImplCorrAvgNormDouble < -0.1 ? color.red : color.gray, style = plot.style_columns)

hline(showImplied or showImpliedNorm or showImpliedNorm2? 0.1  : na, color = color.green, linewidth = 2)
hline(showImplied or showImpliedNorm or showImpliedNorm2? 0    : na)
hline(showImplied or showImpliedNorm or showImpliedNorm2? -0.1 : na, color = color.red  , linewidth = 2)

// Decide on the barcolor
barcolor(implBarCol and showImpliedNorm? ImplCorrAvgNorm       > 0.1  ?color.green : ImplCorrAvgNorm       < -0.1  ? color.red : color.gray : 
     implBarCol and showImpliedNorm2?    ImplCorrAvgNormDouble > 0.1  ?color.green : ImplCorrAvgNormDouble < -0.1  ? color.red : color.gray :
     implBarCol and not showImpliedNorm? ImplCorrAvg           > 0.1  ?color.green : ImplCorrAvg           < -0.1  ? color.red : color.gray : na)

// HMA
ImplValue = showImpliedNorm? ImplCorrAvgNorm : showImpliedNorm2? ImplCorrAvgNormDouble : showImplied? ImplCorrAvg: na
HMA       = ta.hma(ImplValue, MALen)
HMAL      = ta.crossover(HMA,0)
HMAS      = ta.crossunder(HMA,0)

plot(useMA? HMA : na, "HMA", color.purple, 2)
bgcolor(HMASigCol? color.new(HMAL? color.green: HMAS? color.red: na, 60): na)

// Calculate the different regime probabilities based on asset performance - Could certainly be enhanced and brought to higher sophistication... but works anyways... open to suggestions though
Goldilocks  = (rocVO>0?+1:0)   + (rocSPHD>0?+1:0) + (rocEEM>0?+1:0)  + (rocIWM>0?+1:0)  + (rocQQQ>0?+1:0)  + (rocEWZ<0?+1:0) + (rocEWU<0?+1:0)  + (rocIWF<0?+1:0)  + (rocSPY<0?+1:0)  + (rocDXJ<0?+1:0) 
Reflation   = (rocVO>0?+1:0)   + (rocQQQ>0?+1:0)  + (rocMTUM>0?+1:0) + (rocSPY>0?+1:0)  + (rocIWM>0?+1:0)  + (rocFXI<0?+1:0) + (rocEWZ<0?+1:0)  + (rocEWU<0?+1:0)  + (rocSPLV<0?+1:0) + (rocSPHD<0?+1:0)
Inflation   = (rocINDA>0?+1:0) + (rocQQQ>0?+1:0)  + (rocEWZ>0?+1:0)  + (rocSPHD>0?+1:0) + (rocMTUM>0?+1:0) + (rocEEM<0?+1:0) + (rocACWX<0?+1:0) + (rocFXI<0?+1:0)  + (rocEWU<0?+1:0)  + (rocEZU<0?+1:0)
Deflation   = (rocEWU>0?+1:0)  + (rocSPLV>0?+1:0) + (rocSPHD>0?+1:0) + (rocFXI>0?+1:0)  + (rocQUAL>0?+1:0) + (rocEWZ<0?+1:0) + (rocDXJ<0?+1:0)  + (rocSPHB<0?+1:0) + (rocEEM<0?+1:0)  + (rocOEF<0?+1:0)
Denumerator =  Goldilocks + Reflation + Inflation + Deflation
// Find the greatest value among the scenarios
maxValue = math.max(Goldilocks, Reflation, Inflation, Deflation)

// Determine the market scenario based on the greatest value
Risk = ""
if maxValue == Goldilocks or maxValue == Reflation
    Risk := "RISK ON"
else
    Risk := "RISK OFF"
RiskCol     = (Risk == "RISK ON"? color.green : color.red)
RiskBg      = (Risk == "RISK ON"? color.new(color.green, 40) : color.new(color.red, 40))

regime = ""
color regCol = na
if maxValue == Goldilocks
    regime := "Goldilocks"
    regCol := color.new(color.green, 50)
else if maxValue == Reflation
    regime := "Reflation"
    regCol := color.new(color.lime, 50)
else if maxValue == Inflation
    regime := "Inflation"
    regCol := color.new(color.red, 50)
else if maxValue == Deflation
    regime := "Deflation"    
    regCol := color.new(color.blue, 50)


plot   (col? Risk == "RISK ON"? 1 : -1 : na )
bgcolor(col? Risk == "RISK ON"? color.new(color.green, 60) : color.new(color.red, 60):na)
bgcolor(reg? regCol : na)






// Table

var string G2 = "🌌 Table Settings Performance 🌌"
string table_y_pos = input.string(defval = "bottom", title = "Table Position", options = ["top", "middle", "bottom"], group = G2, inline = "1")
string table_x_pos = input.string(defval = "right",  title = "",               options = ["left", "center", "right"], group = G2, inline = "1")

color positive_color_input = color(color.new(color.green, 0))
color negative_color_input = color(color.new(color.red, 0))

var table table = table.new(table_y_pos + "_" + table_x_pos, columns = 10, rows = 17, frame_color = color.white,
 frame_width = 1, border_color = color.white, border_width = 1)

if showPerfTab
    table.merge_cells(table, 0, 0,  7,  0)
    table.merge_cells(table, 0, 1,  1,  1)
    table.merge_cells(table, 2, 1,  3,  1)
    table.merge_cells(table, 4, 1,  5,  1)
    table.merge_cells(table, 6, 1,  7,  1)
    table.merge_cells(table, 0, 2,  7,  2)
    table.merge_cells(table, 0, 8,  7,  8)
    table.merge_cells(table, 0, 14, 7, 14)
    table.merge_cells(table, 0, 16, 7, 16)

 // Definitions
if showPerfTab and barstate.islast
    table.cell(table, 0, 0,  text = "🌌 CE - EQUITY FACTOR "+str.tostring(rocPeriod)+"D 🌌", text_size = i_text_size, text_color = color.purple)
    table.cell(table, 0, 2,  text = "Top 5 Equity Factors ",                                  text_size = i_text_size, text_color = color.green)
    table.cell(table, 0, 8,  text = "Bottom 5 Equity Factors ",                               text_size = i_text_size, text_color = color.red)

    table.cell(table, 0, 14, text = "Risk Period: ",                                          text_size = i_text_size, text_color = color.white)
    table.cell(table, 0, 16, text = Risk,                                                     text_size = i_text_size, text_color = color.white , bgcolor = RiskBg, text_font_family = font.family_monospace)
  
 
    table.cell(table, 0, 1,"GOLDILOCKS",                         text_size = i_text_size, text_color = color.green)                                             
    table.cell(table, 0, 3,"Mid Caps (VO)",                      text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 3,str.tostring(math.round(rocVO,2)),    text_size = i_text_size, text_color = rocVO   > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 4,"Dividend Compounders (SPHD)",        text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 4,str.tostring(math.round(rocSPHD,2)),  text_size = i_text_size, text_color = rocSPHD > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 5,"Emerging Markets (EEM)",             text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 5,str.tostring(math.round(rocEEM,2)),   text_size = i_text_size, text_color = rocEEM  > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 6,"Small Caps (IWM)",                   text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 6,str.tostring(math.round(rocIWM,2)),   text_size = i_text_size, text_color = rocIWM  > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 7,"Mega Cap Growth (QQQ)",              text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 7,str.tostring(math.round(rocQQQ,2)),   text_size = i_text_size, text_color = rocQQQ  > 0  ? positive_color_input : negative_color_input)

    table.cell(table, 0, 9, text = "Brazil (EWZ)",               text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 9,str.tostring(math.round(rocEWZ,2)),   text_size = i_text_size, text_color = rocEWZ  > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 10, text = "United Kingdom (EWU)",      text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 10,str.tostring(math.round(rocEWU,2)),  text_size = i_text_size, text_color = rocEWU  > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 11, text = "Growth (IWF)",              text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 11,str.tostring(math.round(rocIWF,2)),  text_size = i_text_size, text_color = rocIWF  > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 12, text = "United States (SPY)",       text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 12,str.tostring(math.round(rocSPY,2)),  text_size = i_text_size, text_color = rocSPY  > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 13, text = "Japan (DXJ)",               text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 13,str.tostring(math.round(rocDXJ,2)),  text_size = i_text_size, text_color = rocDXJ  > 0  ? positive_color_input : negative_color_input)
    table.cell(table, 0, 15, text = "Goldilocks Probability: ",  text_size = i_text_size, text_color = color.white)
    table.cell(table, 1, 15,str.tostring(math.round(Goldilocks/Denumerator*100, 2))+"% | "+str.tostring(Goldilocks)+ " / 10", text_size = i_text_size, text_color = RiskCol)

    table.cell(table, 2, 1,"REFLATION",                          text_size = i_text_size, text_color = color.lime)         
    table.cell(table, 2, 3,"Mid Caps (VO)",                      text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 3,str.tostring(math.round(rocVO,2)),    text_size = i_text_size, text_color = rocVO   > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 4,"Mega Cap Growth (QQQ)",              text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 4,str.tostring(math.round(rocQQQ,2)),   text_size = i_text_size, text_color = rocQQQ  > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 5,"Momentum (MTUM)",                    text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 5,str.tostring(math.round(rocMTUM,2)),  text_size = i_text_size, text_color = rocMTUM > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 6,"United States (SPY)",                text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 6,str.tostring(math.round(rocSPY,2)),   text_size = i_text_size, text_color = rocSPY  > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 7,"Small Caps (IWM)",                   text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 7,str.tostring(math.round(rocIWM,2)),   text_size = i_text_size, text_color = rocIWM  > 0 ? positive_color_input : negative_color_input)  
    
    table.cell(table, 2, 9, text = "China (FXI)",                text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 9,str.tostring(math.round(rocFXI,2)),   text_size = i_text_size, text_color = rocFXI  > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 10, text = "Brazil (EWZ)",              text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 10,str.tostring(math.round(rocEWZ,2)),  text_size = i_text_size, text_color = rocEWZ  > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 11, text = "United Kingdom (EWU)",      text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 11,str.tostring(math.round(rocEWU,2)),  text_size = i_text_size, text_color = rocEWU  > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 12, text = "Low Beta (SPLV)",           text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 12,str.tostring(math.round(rocSPLV,2)), text_size = i_text_size, text_color = rocSPLV > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 13, text = "Dividend Compounders (SPHD)",text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 13,str.tostring(math.round(rocSPHD,2)), text_size = i_text_size, text_color = rocSPHD > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 2, 15, text = "Reflation Probability: ",   text_size = i_text_size, text_color = color.white)
    table.cell(table, 3, 15,str.tostring(math.round(Reflation/Denumerator*100, 2))+"% | "+str.tostring(Reflation)+ " / 10", text_size = i_text_size, text_color = RiskCol)

    table.cell(table, 4, 1,"INFLATION",                          text_size = i_text_size, text_color = color.red)          
    table.cell(table, 4, 3,"India (INDA)",                       text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 3,str.tostring(math.round(rocINDA,2)),  text_size = i_text_size, text_color = rocINDA > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 4, 4,"Mega Cap Growth (QQQ)",              text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 4,str.tostring(math.round(rocQQQ,2)),   text_size = i_text_size, text_color = rocQQQ > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 4, 5,"Brazil (EWZ)",                       text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 5,str.tostring(math.round(rocEWZ,2)),   text_size = i_text_size, text_color = rocEWZ > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 4, 6,"Dividend Compounders (SPHD)",        text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 6,str.tostring(math.round(rocSPHD,2)),  text_size = i_text_size, text_color = rocSPHD > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 4, 7,"Momentum (MTUM)",                    text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 7,str.tostring(math.round(rocMTUM,2)),  text_size = i_text_size, text_color = rocMTUM > 0 ? positive_color_input : negative_color_input)  

    table.cell(table, 4, 9, text = "Emerging Markets (EEM)",     text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 9,str.tostring(math.round(rocEEM,2)),   text_size = i_text_size, text_color = rocEEM > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 4, 10, text = "International ex-US (ACWX)",text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 10,str.tostring(math.round(rocACWX,2)), text_size = i_text_size, text_color = rocACWX > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 4, 11, text = "China (FXI)",               text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 11,str.tostring(math.round(rocFXI,2)),  text_size = i_text_size, text_color = rocFXI > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 4, 12, text = "United Kingdom (EWU)",      text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 12,str.tostring(math.round(rocEWU,2)),  text_size = i_text_size, text_color = rocEWU > 0 ? positive_color_input : negative_color_input)  
    table.cell(table, 4, 13, text = "Eurozone (EZU)",            text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 13,str.tostring(math.round(rocEZU,2)),  text_size = i_text_size, text_color = rocEZU > 0 ? positive_color_input : negative_color_input)  
    table.cell(table, 4, 15, text = "Inflation Probability: ",   text_size = i_text_size, text_color = color.white)
    table.cell(table, 5, 15,str.tostring(math.round(Inflation/Denumerator*100, 2))+"% | "+str.tostring(Inflation)+ " / 10", text_size = i_text_size, text_color = RiskCol)

    table.cell(table, 6, 1,"DEFLATION",                          text_size = i_text_size, text_color = color.blue)        
    table.cell(table, 6, 3,"United Kingdom (EWU)",               text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 3,str.tostring(math.round(rocEWU,2)),   text_size = i_text_size, text_color = rocEWU > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 6, 4,"Low Beta (SPLV)",                    text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 4,str.tostring(math.round(rocSPLV,2)),  text_size = i_text_size, text_color = rocSPLV > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 6, 5,"Dividend Compounders (SPHD)",        text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 5,str.tostring(math.round(rocSPHD,2)),  text_size = i_text_size, text_color = rocSPHD > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 6, 6,"China (FXI)",                        text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 6,str.tostring(math.round(rocFXI,2)),   text_size = i_text_size, text_color = rocFXI > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 6, 7,"Quality (QUAL)",                     text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 7,str.tostring(math.round(rocQUAL,2)),  text_size = i_text_size, text_color = rocQUAL > 0 ? positive_color_input : negative_color_input)

    table.cell(table, 6, 9, text = "Brazil (EWZ)",               text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 9,str.tostring(math.round(rocEWZ,2)),   text_size = i_text_size, text_color = rocEWZ > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 6, 10, text = "Japan (DXJ)",               text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 10,str.tostring(math.round(rocDXJ,2)),  text_size = i_text_size, text_color = rocDXJ > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 6, 11, text = "High Beta (SPHB)",          text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 11,str.tostring(math.round(rocSPHB,2)), text_size = i_text_size, text_color = rocSPHB > 0 ? positive_color_input : negative_color_input)
    table.cell(table, 6, 12, text = "Emerging Markets (EEM)",    text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 12,str.tostring(math.round(rocEEM,2)),  text_size = i_text_size, text_color = rocEEM > 0 ? positive_color_input : negative_color_input)  
    table.cell(table, 6, 13, text = "Size (OEF)",                text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 13,str.tostring(math.round(rocOEF,2)),  text_size = i_text_size, text_color = rocOEF > 0 ? positive_color_input : negative_color_input)  
    table.cell(table, 6, 15, text = "Deflation Probability: ",   text_size = i_text_size, text_color = color.white)
    table.cell(table, 7, 15,str.tostring(math.round(Deflation/Denumerator*100, 2))+"% | "+str.tostring(Deflation)+ " / 10", text_size = i_text_size, text_color = RiskCol)

Overview

CE - 42MACRO Equity Factor Table can show a correlation table over a chosen length and a performance table based on rate of change or Sharpe ratio. Optional implied correlation plots, including single and double normalization, may overlay a Hull moving average with background or bar coloring. Approximate macroeconomic grid regimes and risk-on versus risk-off periods can be shown. Table position and text size are adjustable. No trade entries, exits, or stop rules are defined.

Details

Published by

regalouisei on GitHub

Code credit

Celestial-Eye, as written in the script's header

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Screeners & dashboards, Oscillators & momentum

Markets

Stocks

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Show Correlation TablebooltrueshowCorrTab
Correlation Lengthint14l
Show Performance TablebooltrueshowPerfTab
RoC Periodint14rocPeriod
Use Sharpe instead of Rate of ChangeboolfalseuseSharpe
Show Implied Correlation?boolfalseshowImplied
Show Normalized Implied Correlation?boolfalseshowImpliedNorm
Normalization lookbackint50norm_periodImpl
Show double Normalized Implied Correlation?boolfalseshowImpliedNorm2
Second Normalization lookbackint40norm_periodImpl2
Overlay HMA for slightly earlier signals?booltrueuseMA
Lenght of HMAint3MALen
Show all 25 settings
SettingTypeDefaultVariable
Background Coloring for HMA SignalsboolfalseHMASigCol
Barcoloring for Impl. Correlation?boolfalseimplBarCol
Show approximate Macroeconomic GRID Regimesboolfalsereg
Show Risk On - Risk Off periodsboolfalsecol
Fast Periodint7fast_period
Slow Periodint19slow_period
Efficiency Ratio Periodint8er_period
Normalization lookbackint10norm_period
Table Positionstringtoptable0_y_pos
table0_x_posstringrighttable0_x_pos
Text Size:stringsize.tinyi_text_size
Table Positionstringbottomtable_y_pos
table_x_posstringrighttable_x_pos
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

This indicator scans a pasted list of symbols for RSI directional momentum and shows matching long and short signals in a table in a separate pane. The user chooses continuous break, continuous retracement, flip break, flip retracement, divergence, or hidden d

Indicator v6 Oscillators & momentumDivergence
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Scanner
261 stars

This indicator plots the RSI oscillator on the main chart and displays its value distribution in a table positioned at the top right. The script calculates the relative strength index using the input source and length, then plots horizontal lines at 0, 50, and

Indicator v4 Oscillators & momentumScreeners & dashboards
Updated 4 years ago · None stated GitHub repository of Tables-003 Oscillator Distribution

Market Speedometer

by TradersPost
218 stars

Market Speedometer plots a 0-100 market speed reading in a separate pane. It measures movement by bar-to-bar change, true range, or a short average of recent bars, then ranks that movement against ATR and a percentile lookback. An EMA smooths the reading, and

Indicator v6 Volatility & bandsOscillators & momentum
Updated 3 months ago · None stated GitHub repository of Market Speedometer

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama
114 stars

Calculates normalized reversal metrics across up to ten Forex currency pairs using user-selected moving average methods, including HarmonicMA, EMA, SMA, or WMA. The indicator identifies overbought, oversold, and mean-crossing conditions using a configurable th

Indicator v4 Screeners & dashboardsMean reversion
Updated 1 year ago · None stated GitHub repository of Multi-Pair Trend Reversal Widget

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers