I'm wondering if there would be any indicator/script that one can plot industry and/or sector as an indicator in TOS?
For example, for each ticker we have on the cart, get the industry/sector and plot as what we see on TC2000 or finviz https://www.finviz.com/groups.ashx?g=sector&v=410&o=name
This would be very useful indicator.
For example, for each ticker we have on the cart, get the industry/sector and plot as what we see on TC2000 or finviz https://www.finviz.com/groups.ashx?g=sector&v=410&o=name
This would be very useful indicator.
Code:
# S&P 500 Sector Performance (Percentage)
# Paris
# 4.12.2018
# After reviewing chubbyboy's S&P sector study, I thought it might
# be a good idea to display labels of relative S&P sector performance
# in percentages. At one glance this will enable us to determine
# which sectors are happening and which are not. Decided to use a
# script() to retrieve the data. Also, I changed the formula slightly.
# The percentage displayed is the current price as a percentage over
# yesterday's closing rather than the open today as was used in chubbyboy's
# study.
script Sector {
input symb = "SPX";
def c = close(symbol = symb, period = AggregationPeriod.DAY);
def PctChg = (c / c[1]) - 1;
plot pct = PctChg;
}
def SPX = Sector("SPX");
def Energy = Sector("$SP500#10");
def ConDisr = Sector("$SP500#25");
def Finance = Sector("$SP500#40");
def Utilities = Sector("$SP500#55");
def Materials = Sector("$SP500#15");
def ConStaple = Sector("$SP500#30");
def InfoTech = Sector("$SP500#45");
def RealEste = Sector("$SP500#60");
def Industrl = Sector("$SP500#20");
def Health = Sector("$SP500#35");
def Telecoms = Sector("$SP500#50");
AddLabel(1, "S&P Sector Performance", Color.ORANGE);
AddLabel(1, "SPX: " + AsPercent(SPX), if Energy > 0 then Color.GREEN else if SPX < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Energy: " + AsPercent(Energy), if Energy > 0 then Color.GREEN else if Energy < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Consumer Discretionary: " + AsPercent(ConDisr), if ConDisr > 0 then Color.GREEN else if ConDisr < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Financials: " + AsPercent(Finance), if Finance > 0 then Color.GREEN else if Finance < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Utilities: " + AsPercent(Utilities), if Utilities > 0 then Color.GREEN else if Utilities < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Materials: " + AsPercent(Materials), if Materials > 0 then Color.GREEN else if Materials < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Consumer Staples: " + AsPercent(ConStaple), if ConStaple > 0 then Color.GREEN else if ConStaple < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Info Tech: " + AsPercent(InfoTech), if InfoTech > 0 then Color.GREEN else if InfoTech < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Real Estate: " + AsPercent(RealEste), if RealEste > 0 then Color.GREEN else if RealEste < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Industrials: " + AsPercent(Industrl), if Industrl > 0 then Color.GREEN else if Industrl < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Health Care: " + AsPercent(Health), if Health > 0 then Color.GREEN else if Health < 0 then Color.RED else Color.LIGHT_GRAY);
AddLabel(1, "Telecoms: " + AsPercent(Telecoms), if Telecoms > 0 then Color.GREEN else if Telecoms < 0 then Color.RED else Color.LIGHT_GRAY);
# End Study