declare lower;
HidePricePlot();
script PC {
input Sym = "SPY";
def isFirstBar = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
def O = if isFirstBar then close(Sym) else O[1];
def C = close(Sym);
plot PC = (C - O) / O;
}
def cXLK = PC("XLK");
def cXLY = PC("XLY");
def cXLV = PC("XLV");
def cXLF = PC("XLF");
def cXLC = PC("XLC");
def cXLI = PC("XLI");
def cXLP = PC("XLP");
def cXLRE = PC("XLRE");
def cXLE = PC("XLE");
def cXLB = PC("XLB");
def cXLU = PC("XLU");
# Weights updated on 02/01/2024
def wXLK = cXLK * 29.5; # Information Technology
AddLabel(yes, "InfoTech 29.5%: " + wXLK, (if wXLK > 0 then
Color.GREEN else if wXLK < 0 then Color.RED else Color.GRAY) );
def wXLY = cXLY * 10.3; # Consumer Discretionary
AddLabel(yes, "ConsumerDis 10.3%: " + wXLY, (if wXLY > 0 then
Color.GREEN else if wXLY < 0 then Color.RED else Color.GRAY) );
def wXLV = cXLV * 12.8; # Healthcare
AddLabel(yes, "Healthcare 12.8%: " + wXLV, (if wXLV > 0 then
Color.GREEN else if wXLV < 0 then Color.RED else Color.GRAY) );
def wXLF = cXLF * 13.1; # Financial
AddLabel(yes, "Financial 13.1%: " + wXLF, (if wXLF > 0 then
Color.GREEN else if wXLF < 0 then Color.RED else Color.GRAY) );
def wXLC = cXLC * 8.9; # Communications Services
AddLabel(yes, "Comms 8.9%: " + wXLC, (if wXLC > 0 then
Color.GREEN else if wXLC < 0 then Color.RED else Color.GRAY) );
def wXLI = cXLI * 8.6; # Industrial
AddLabel(yes, "Industrial 8.6%: " + wXLI, (if wXLI > 0 then
Color.GREEN else if wXLI < 0 then Color.RED else Color.GRAY) );
def wXLP = cXLP * 6.1; # Consumer Staples
AddLabel(yes, "ConsumerSta 6.1%: " + wXLP, (if wXLP > 0 then
Color.GREEN else if wXLP < 0 then Color.RED else Color.GRAY) );
def wXLRE = cXLRE * 2.4; # Real Estate
AddLabel(yes, "RealEstate 2.4%: " + wXLRE, (if wXLRE > 0 then
Color.GREEN else if wXLRE < 0 then Color.RED else Color.GRAY) );
def wXLE = cXLE * 3.8; # Energy
AddLabel(yes, "Energy 3.8%: " + wXLE, (if wXLE > 0 then
Color.GREEN else if wXLE < 0 then Color.RED else Color.GRAY) );
def wXLB = cXLB * 2.3; # Materials
AddLabel(yes, "Materials 2.3%: " + wXLB, (if wXLB > 0 then
Color.GREEN else if wXLB < 0 then Color.RED else Color.GRAY) );
def wXLU = cXLU * 2.2; # Utilities
AddLabel(yes, "Utilities 2.2%: " + wXLU, (if wXLU > 0 then
Color.GREEN else if wXLU < 0 then Color.RED else Color.GRAY) );
def wTotal =
wXLK + wXLY + wXLV +
wXLF + wXLC + wXLI +
wXLP + wXLRE + wXLE +
wXLB + wXLU
;
def uTotal =
cXLK + cXLY + cXLV +
cXLF + cXLC + cXLI +
cXLP + cXLRE + cXLE +
cXLB + cXLU
;
plot Histo = wTotal / 11;
plot Line = uTotal;
Line.SetDefaultColor(Color.GRAY);
Line.SetLineWeight(1);
Histo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Histo.AssignValueColor(if Histo > Histo[1] then Color.PLUM else Color.YELLOW);
Histo.SetLineWeight(1);
plot z = 0;