Message
Message
Message
# Created by Randy Haben for Shadow Trader based on an older ST sector box script
# Copyright (c) 2022 Shadow Trader and Karstware Studios
# This script is intended strictly for educational use. No claims are made as to
its accuracy. Trades made based on this indicator are solely the responsibility of
the trader.
#hint: \nThis is an upgrade to the Shadow Trader Sector Box study. It tracks the
percentage change in each of the 11 sectors that comprise the S&P 500.\n\n - The
values are only updated during Regular Trading Hours. But they remain visible as
fixed values between sessions.\n\n - The label colors can be changed as needed for
accessibility or preference. Lighter colors indicate minor price changes since
open. \n\n - You may update sector weights in the settings. The values will be
correct, but the display order will not change until the script source code is
updated.</li>
declare lower;
# Snippet for determining whether the current bar is in Regular Trading Hours
# Begin KW_RTH
script na {
plot na = Double.NaN;
}
script date {
plot date = GetYYYYMMDD();
}
script rthStart {
plot rthStart = RegularTradingStart(date()) / AggregationPeriod.MIN;
}
script rthEnd {
plot rthEnd = RegularTradingEnd(date()) / AggregationPeriod.MIN;
}
script firstBar {
plot firstBar = BarNumber() == 1;
}
script rth {
plot rth;
plot tod = (GetTime() / AggregationPeriod.MIN);
rth = tod between rthStart() and rthEnd();
}
script globex {
plot globex = !rth();
}
script intraDay {
plot intraDay = GetAggregationPeriod() < AggregationPeriod.DAY;
}
script datechanged {
plot datechanged = date() != date()[1];
}
script rthchanged {
plot rthchanged = rth() != rth()[1];
}
script rthstarted {
plot rthstarted;
rthstarted = rth() and (rthchanged() or datechanged());
}
script rthended {
plot rthended;
plot rth = rth();
rthended = rthStarted() or (!rth() and rthchanged());
}
# End KW_RTH
DefineGlobalColor("1", Color.LIGHT_RED);
DefineGlobalColor("2", GetColor(5));
DefineGlobalColor("3", Color.LIGHT_GREEN);
DefineGlobalColor("4", Color.GREEN);
script opn {
plot r;
input cur = 0;
input prev = 0;
r = If(
!intraDay(), Double.NaN,
If(
firstBar(),
If(rth(), cur, Double.NaN),
If(rthStarted() and !IsNaN(cur), cur, prev)
)
);
}
script cls {
input cur = 0;
input prev = 0;
plot cls;
plot rth = rth();
cls = If(
!intraDay(), Double.NaN,
If(
firstBar(),
If(rth, cur, Double.NaN),
If(rth and !IsNaN(cur), cur, prev)
)
);
}
script pct {
plot r;
input op = 0;
input cl = 0;
#hint xlk: You may update sector weights in the settings. The values will be
correct, but the display order will not change until the script source code is
updated.
AddLabel(show, "Intech " + AsText(XLK) + "% | " + AsText(kp) + "%", if (kp < -.5)
then GlobalColor("1")
else if kp < 0 then GlobalColor("2")
else if kp > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "Hlthcare " + AsText(XLV) + "% | " + AsText(vp) + "%", if (vp < -.5)
then GlobalColor("1")
else if vp < 0 then GlobalColor("2")
else if vp > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "ConsDis " + AsText(XLY) + "% | " + AsText(yp) + "%", if (yp < -.5)
then GlobalColor("1")
else if yp < 0 then GlobalColor("2")
else if yp > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "Fins " + AsText(XLF) + "% | " + AsText(fp) + "%", if (fp < -.5)
then GlobalColor("1")
else if fp < 0 then GlobalColor("2")
else if fp > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "Indus " + AsText(XLI) + "% | " + AsText(ip) + "%", if (ip < -.5)
then GlobalColor("1")
else if ip < 0 then GlobalColor("2")
else if ip > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "Staples " + AsText(XLP) + "% | " + AsText(pp) + "%", if (pp < -.5)
then GlobalColor("1")
else if pp < 0 then GlobalColor("2")
else if pp > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "Enrgy " + AsText(XLE) + "% | " + AsText(ep) + "%", if (ep < -.5)
then GlobalColor("1")
else if ep < 0 then GlobalColor("2")
else if ep > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "Utes " + AsText(XLU) + "% | " + AsText(up) + "%", if (up < -.5)
then GlobalColor("1")
else if up < 0 then GlobalColor("2")
else if up > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "REste " + AsText(XLRE) + "% | " + AsText(rep) + "%", if (rep < -.5)
then GlobalColor("1")
else if rep < 0 then GlobalColor("2")
else if rep > .5 then GlobalColor("4")
else GlobalColor("3")
);
AddLabel(show, "Mats " + AsText(XLB) + "% | " + AsText(bp) + "%", if (bp < -.5)
then GlobalColor("1")
else if bp < 0 then GlobalColor("2")
else if bp > .5 then GlobalColor("4")
else GlobalColor("3")
);