Firstly, I do agree that the SPX is the weighted $ADSPD. You can verify this by plotting the ADSPD and SPX on the same chart but on different axis. Nevertheless, here be my attempt.
Code:
#declare upper;
declare once_per_bar;
declare real_size;
declare lower;
HidePricePlot(yes);
input Roundness = 2;
input Indicator = "$ADSPD";
# https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data
def XLK_WT = 26.65;
def XLV_WT = 14.59;
def XLF_WT = 10.98;
def XLY_WT = 10.79;
def XLC_WT = 8.94;
def XLI_WT = 7.93;
def XLP_WT = 6.95;
def XLE_WT = 4.53;
def XLU_WT = 2.94;
def XLRE_WT = 2.77;
def XLB_WT = 2.71;
def aggregationPeriod = AggregationPeriod.DAY; #
plot Metric = close(Indicator);
Metric.SetDefaultColor(CreateColor(255,255,255));
input c = 120; #HINT: Scaling factor
AddLabel(yes, Indicator + " scaling " + c);
def XLKo = open("XLK", period = aggregationPeriod);
def XLKpchg = (close("XLK", period = GetAggregationPeriod()) - XLKo)/XLKo;
def XLVo = open("XLV", period = aggregationPeriod);
def XLVpchg = (close("XLV", period = GetAggregationPeriod()) - XLVo)/XLVo;
def XLYo = open("XLY", period = aggregationPeriod);
def XLYpchg = (close("XLY", period = GetAggregationPeriod()) - XLYo)/XLYo;
def XLFo = open("XLF", period = aggregationPeriod);
def XLFpchg = (close("XLF", period = GetAggregationPeriod()) - XLFo)/XLFo;
def XLCo = open("XLC", period = aggregationPeriod);
def XLCpchg = (close("XLC", period = GetAggregationPeriod()) - XLCo)/XLCo;
def XLIo = open("XLI", period = aggregationPeriod);
def XLIpchg = (close("XLI", period = GetAggregationPeriod()) - XLIo)/XLIo;
def XLPo = open("XLP", period = aggregationPeriod);
def XLPpchg = (close("XLP", period = GetAggregationPeriod()) - XLPo)/XLPo;
def XLEo = open("XLE", period = aggregationPeriod);
def XLEpchg = (close("XLE", period = GetAggregationPeriod()) - XLEo)/XLEo;
def XLUo = open("XLU", period = aggregationPeriod);
def XLUpchg = (close("XLU", period = GetAggregationPeriod()) - XLUo)/XLUo;
def XLBo = open("XLB", period = aggregationPeriod);
def XLBpchg = (close("XLB", period = GetAggregationPeriod()) - XLBo)/XLBo;
def XLREo = open("XLRE", period = aggregationPeriod);
def XLREpchg = (close("XLRE", period = GetAggregationPeriod()) - XLREo)/XLREo;
def SPYo = open("SPY", period = aggregationPeriod);
def SPYchg = (close("SPY", period = GetAggregationPeriod()) - SPYo)/SPYo;
# $ for c in XLK XLV XLY XLF XLC XLI XLP XLE XLU XLB XLRE; do echo "+c * ${c}_WT * sign(${c}pchg)"; done
DefineGlobalColor("MetricUp", CreateColor(128, 0, 64));
DefineGlobalColor("MetricDown", CreateColor(64, 64, 64));
plot Spy = c * SPYchg * 100;
Spy.setLineWeight(2);
Spy.setDefaultColor(Color.Magenta);
plot WeightedMetric =
c * XLK_WT * XLKpchg
+c * XLV_WT * XLVpchg
+c * XLY_WT * XLYpchg
+c * XLF_WT * XLFpchg
+c * XLC_WT * XLCpchg
+c * XLI_WT * XLIpchg
+c * XLP_WT * XLPpchg
+c * XLE_WT * XLEpchg
+c * XLU_WT * XLUpchg
+c * XLB_WT * XLBpchg
+c * XLRE_WT * XLREpchg;
WeightedMetric.DefineColor("Up", CreateColor(128, 0, 128));
WeightedMetric.DefineColor("Down", CreateColor(64, 64, 128));
WeightedMetric.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
WeightedMetric.AssignValueColor(if WeightedMetric > WeightedMetric[1] then WeightedMetric.Color("Up") else WeightedMetric.Color("Down"));
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(9));
ZeroLine.HideTitle();
ZeroLine.HideBubble();
Code: