Sector Laggers & Leaders Labels for ThinkorSwim

AlexsOptions

New member
V1 :

Shows % change compared to yesterday's close and current price. If % change is positive it will be green if neg. it will be red. The leader (highest % change) for the day will be in pink.

http://tos.mx/TsidmSY
unknown.png


V2:

Shows green if above yesterdays high, shows red if below yesterday's high and shows white if current price is above yesterdays low and below yesterdays high.
http://tos.mx/S8B534Z
unknown.png


You can change the tickers as you wish, just know you will have to change the code in order to change the name, it's all hard coded in & if anyone is able to shorten it up that'd be helpful. No clue how TOS's language is structured so have no clue how I would shorten up the huge checks against all other tickers.


V1 CODE :
Code:
input SNP = "SPY";
input IWM = "IWM";
input QQQ = "QQQ";
input XLC = "XLC";
input XLY = "XLY";
input XLP = "XLP";
input XLE = "XLE";
input XLF = "XLF";
input XLV = "XLV";
input XLI = "XLI";
input XLB = "XLB";
input XLRE = "XLRE";
input XLK = "XLK";
input XLU = "XLU";

def IWMC = close(IWM, period = AggregationPeriod.DAY);
def IWMO =  close(IWM, period = AggregationPeriod.DAY)[1];
def IWMD = IWMC - IWMO;
def IWMPCT = IWMD / IWMO;

def QQQC = close(QQQ, period = AggregationPeriod.DAY);
def QQQO = close(QQQ, period = AggregationPeriod.DAY)[1];
def QQQD = QQQC - QQQO;
def QQQPCT = QQQD / QQQO;

def XLCC = close(XLC, period = AggregationPeriod.DAY);
def XLCO = close(XLC, period = AggregationPeriod.DAY)[1];
def XLCD = XLCC - XLCO;
def XLCPCT = XLCD / XLCO;

def XLYC = close(XLY, period = AggregationPeriod.DAY);
def XLYO = close(XLY, period = AggregationPeriod.DAY)[1];
def XLYD = XLYC - XLYO;
def XLYPCT = XLYD / XLYO;

def XLPC = close(XLP, period = AggregationPeriod.DAY);
def XLPO = close(XLP, period = AggregationPeriod.DAY)[1];
def XLPD = XLPC - XLPO;
def XLPPCT = XLPD / XLPO;

def XLEC = close(XLE, period = AggregationPeriod.DAY);
def XLEO = close(XLE, period = AggregationPeriod.DAY)[1];
def XLED = XLEC - XLEO;
def XLEPCT = XLED / XLEO;

def XLFC = close(XLF, period = AggregationPeriod.DAY);
def XLFO = close(XLF, period = AggregationPeriod.DAY)[1];
def XLFD = XLFC - XLFO;
def XLFPCT = XLFD / XLFO;

def XLVC = close(XLV, period = AggregationPeriod.DAY);
def XLVO = close(XLV, period = AggregationPeriod.DAY)[1];
def XLVD = XLVC - XLVO;
def XLVPCT = XLVD / XLVO;

def XLIC = close(XLI, period = AggregationPeriod.DAY);
def XLIO = close(XLI, period = AggregationPeriod.DAY)[1];
def XLID = XLIC - XLIO;
def XLIPCT = XLID / XLIO;

def XLREC = close(XLRE, period = AggregationPeriod.DAY);
def XLREO = close(XLRE, period = AggregationPeriod.DAY)[1];
def XLRED = XLREC - XLREO;
def XLREPCT = XLRED / XLREO;

def XLKC = close(XLK, period = AggregationPeriod.DAY);
def XLKO = close(XLK, period = AggregationPeriod.DAY)[1];
def XLKD = XLKC - XLKO;
def XLKPCT = XLKD / XLKO;

def XLBC = close(XLB, period = AggregationPeriod.DAY);
def XLBO = close(XLB, period = AggregationPeriod.DAY)[1];
def XLBD = XLBC - XLBO;
def XLBPCT = XLBD / XLBO;

def XLUC = close(XLU, period = AggregationPeriod.DAY);
def XLUO = close(XLU, period = AggregationPeriod.DAY)[1];
def XLUD = XLUC - XLUO;
def XLUPCT = XLUD / XLUO;

def SNPC = close(SNP, period = AggregationPeriod.DAY);
def SNPO =  close(SNP, period = AggregationPeriod.DAY)[1];
def SNPD = SNPC - SNPO;
def SNPPCT = SNPD / SNPO;
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"SPY: " + AsPercent(SNPPCT) + "", if SNPPCT > XLFPCT and SNPPCT > XLVPCT and SNPPCT > XLIPCT and SNPPCT > XLBPCT and SNPPCT > XLYPCT and SNPPCT > XLREPCT and SNPPCT > XLUPCT and SNPPCT > XLEPCT and SNPPCT > XLYPCT and SNPPCT > XLCPCT and SNPPCT > QQQPCT and SNPPCT > XLPPCT and SNPPCT > IWMPCT  then Color.PINK else if SNPPCT > 0 then Color.GREEN else Color.RED
);




######################
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"IWM: " + AsPercent(IWMPCT) + "", if IWMPCT > XLFPCT and IWMPCT > XLVPCT and IWMPCT > XLIPCT and IWMPCT > XLBPCT and IWMPCT > XLYPCT and IWMPCT > XLREPCT and IWMPCT > XLUPCT and IWMPCT > XLEPCT and IWMPCT > XLYPCT and IWMPCT > XLCPCT and IWMPCT > QQQPCT and IWMPCT > XLPPCT and IWMPCT > SNPPCT  then Color.PINK else if IWMPCT > 0 then Color.GREEN else Color.RED
);




########################
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"QQQ: " + AsPercent(QQQPCT) + "", if QQQPCT > XLFPCT and QQQPCT > XLVPCT and QQQPCT > XLIPCT and QQQPCT > XLBPCT and QQQPCT > XLYPCT and QQQPCT > XLREPCT and QQQPCT > XLUPCT and QQQPCT > XLEPCT and QQQPCT > XLYPCT and QQQPCT > XLCPCT and QQQPCT > IWMPCT and QQQPCT > XLPPCT and QQQPCT > SNPPCT  then Color.PINK else if QQQPCT > 0 then Color.GREEN else Color.RED
);




######################
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLC: " + AsPercent(XLCPCT) + "",if XLCPCT > XLFPCT and XLCPCT > XLVPCT and XLCPCT > XLIPCT and XLCPCT > XLBPCT and XLCPCT > XLYPCT and XLCPCT > XLREPCT and XLCPCT > XLUPCT and XLCPCT > XLEPCT and XLCPCT > XLYPCT and XLCPCT > QQQPCT and XLCPCT > IWMPCT and XLCPCT > XLPPCT and XLCPCT > SNPPCT  then Color.PINK else if XLCPCT > 0 then Color.GREEN else Color.RED
);


#########################
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLY: " + AsPercent(XLYPCT) + "",  if XLYPCT > XLFPCT and XLYPCT > XLVPCT and XLYPCT > XLIPCT and XLYPCT > XLBPCT and XLYPCT > XLCPCT and XLYPCT > XLREPCT and XLYPCT > XLUPCT and XLYPCT > XLEPCT and XLYPCT > XLCPCT and XLYPCT > QQQPCT and XLYPCT > IWMPCT and XLYPCT > XLPPCT and XLYPCT > SNPPCT  then Color.PINK else if XLYPCT > 0 then Color.GREEN else Color.RED
);


#############################
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLP: " + AsPercent(XLPPCT) + "", if XLPPCT > XLFPCT and XLPPCT > XLVPCT and XLPPCT > XLIPCT and XLPPCT > XLBPCT and XLPPCT > XLCPCT and XLPPCT > XLREPCT and XLPPCT > XLUPCT and XLPPCT > XLEPCT and XLPPCT > XLCPCT and XLPPCT > QQQPCT and XLPPCT > IWMPCT and XLPPCT > XLYPCT and XLPPCT > SNPPCT  then Color.PINK else if XLPPCT > 0 then Color.GREEN else Color.RED
);





#############
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLE: " + AsPercent(XLEPCT) + "", if XLEPCT > XLFPCT and XLEPCT > XLVPCT and XLEPCT > XLPPCT and XLEPCT > XLBPCT and XLEPCT > XLCPCT and XLEPCT > XLREPCT and XLEPCT > XLUPCT and XLEPCT > XLIPCT and XLEPCT > XLCPCT and XLEPCT > QQQPCT and XLEPCT > IWMPCT and XLEPCT > XLYPCT and XLEPCT > SNPPCT  then Color.PINK else if XLEPCT > 0 then Color.GREEN else Color.RED
);








DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLF: " + AsPercent(XLFPCT) + "", if XLFPCT > XLVPCT and XLFPCT > XLIPCT and XLFPCT > XLBPCT and XLFPCT > XLREPCT and XLFPCT > XLKPCT and XLFPCT > XLUPCT and XLFPCT > XLEPCT and XLFPCT > XLPPCT and XLFPCT > XLCPCT and XLFPCT > QQQPCT and XLFPCT > IWMPCT and XLFPCT > XLYPCT and XLFPCT > SNPPCT  then Color.PINK else if XLFPCT > 0 then Color.GREEN else Color.RED
);




DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLV: " + AsPercent(XLVPCT) + "", if XLVPCT > XLFPCT and XLVPCT > XLIPCT and XLVPCT > XLBPCT and XLVPCT > XLREPCT and XLVPCT > XLKPCT and XLVPCT > XLUPCT and XLVPCT > XLEPCT and XLVPCT > XLPPCT and XLVPCT > XLCPCT and XLVPCT > QQQPCT and XLVPCT > IWMPCT and XLVPCT > XLYPCT and XLVPCT > SNPPCT  then Color.PINK else if XLVPCT > 0 then Color.GREEN else Color.RED
);







DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLI: " + AsPercent(XLIPCT) + "", if XLIPCT > XLFPCT and XLIPCT > XLVPCT and XLIPCT > XLBPCT and XLIPCT > XLREPCT and XLIPCT > XLKPCT and XLIPCT > XLUPCT and XLIPCT > XLEPCT and XLIPCT > XLPPCT and XLIPCT > XLCPCT and XLIPCT > QQQPCT and XLIPCT > IWMPCT and XLIPCT > XLYPCT and XLIPCT > SNPPCT  then Color.PINK else if XLIPCT > 0 then Color.GREEN else Color.RED
);






DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLB: " + AsPercent(XLBPCT) + "", if XLBPCT > XLFPCT and XLBPCT > XLVPCT and XLBPCT > XLPPCT and XLBPCT > XLREPCT and XLBPCT > XLKPCT and XLBPCT > XLUPCT and XLBPCT > XLEPCT and XLBPCT > XLPPCT and XLBPCT > XLCPCT and XLBPCT > QQQPCT and XLBPCT > IWMPCT and XLBPCT > XLYPCT and XLBPCT > SNPPCT  then Color.PINK else if XLBPCT > 0 then Color.GREEN else Color.RED
);

##########
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLRE: " + AsPercent(XLREPCT) + "", if XLREPCT > XLFPCT and XLREPCT > XLVPCT and XLREPCT > XLPPCT and XLREPCT > XLBPCT and XLREPCT > XLKPCT and XLREPCT > XLUPCT and XLREPCT > XLEPCT and XLREPCT > XLPPCT and XLREPCT > XLCPCT and XLREPCT > QQQPCT and XLREPCT > IWMPCT and XLREPCT > XLYPCT and XLREPCT > SNPPCT  then Color.PINK else if XLREPCT > 0 then Color.GREEN else Color.RED
);



##############################
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLK: " + AsPercent(XLKPCT) + "", if XLKPCT > XLFPCT and XLKPCT > XLVPCT and XLKPCT > XLPPCT and XLKPCT > XLBPCT and XLKPCT > XLUPCT and XLKPCT > XLREPCT and XLKPCT > XLEPCT and XLKPCT > XLPPCT and XLKPCT > XLCPCT and XLKPCT > QQQPCT and XLKPCT > IWMPCT and XLKPCT > XLYPCT and XLKPCT > SNPPCT  then Color.PINK else if XLKPCT > 0 then Color.GREEN else Color.RED
);







###########################
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes,"XLU: " + AsPercent(XLUPCT) + "", if XLUPCT > XLFPCT and XLUPCT > XLVPCT and XLUPCT > XLPPCT and XLUPCT > XLBPCT and XLUPCT > XLCPCT and XLUPCT > XLREPCT and XLUPCT > XLEPCT and XLUPCT > XLPPCT and XLUPCT > XLCPCT and XLUPCT > QQQPCT and XLUPCT > IWMPCT and XLUPCT > XLYPCT and XLUPCT > SNPPCT  then Color.PINK else if XLUPCT > 0 then Color.GREEN else Color.RED
);


V2 CODE :
Code:
input SNP = "SPY";
input IWM = "IWM";
input QQQ = "QQQ";
input XLC = "XLC";
input XLY = "XLY";
input XLP = "XLP";
input XLE = "XLE";
input XLF = "XLF";
input XLV = "XLV";
input XLI = "XLI";
input XLB = "XLB";
input XLRE = "XLRE";
input XLK = "XLK";
input XLU = "XLU";

def IWMC = close(IWM, period = AggregationPeriod.DAY);
def IWMH =  high(IWM, period = AggregationPeriod.DAY)[1];
def IWML = low(IWM, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"IWM", if IWMC>IWMH then Color.GREEN else if IWMC < IWML then Color.RED else Color.WHITE);

def QQQC = close(QQQ, period = AggregationPeriod.DAY);
def QQQH =  high(QQQ, period = AggregationPeriod.DAY)[1];
def QQQL = low(QQQ, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"QQQ", if QQQC>QQQH then Color.GREEN else if QQQC < QQQL then Color.RED else Color.WHITE);


def XLCC = close(XLC, period = AggregationPeriod.DAY);
def XLCH =  high(XLC, period = AggregationPeriod.DAY)[1];
def XLCL = low(XLC, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLC", if XLCC>XLCH then Color.GREEN else if XLCC < XLCL then Color.RED else Color.WHITE);


def XLYC = close(XLY, period = AggregationPeriod.DAY);
def XLYH =  high(XLY, period = AggregationPeriod.DAY)[1];
def XLYL = low(XLY, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLY", if XLYC>XLYH then Color.GREEN else if XLYC < XLYL then Color.RED else Color.WHITE);

def XLPC = close(XLP, period = AggregationPeriod.DAY);
def XLPH =  high(XLP, period = AggregationPeriod.DAY)[1];
def XLPL = low(XLP, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLP", if XLPC>XLPH then Color.GREEN else if XLPC < XLPL then Color.RED else Color.WHITE);


def XLEC = close(XLE, period = AggregationPeriod.DAY);
def XLEH =  high(XLE, period = AggregationPeriod.DAY)[1];
def XLEL = low(XLE, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLE", if XLEC>XLEH then Color.GREEN else if XLEC < XLEL then Color.RED else Color.WHITE);



def XLFC = close(XLF, period = AggregationPeriod.DAY);
def XLFH =  high(XLF, period = AggregationPeriod.DAY)[1];
def XLFL = low(XLF, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLF", if XLFC>XLFH then Color.GREEN else if XLFC < XLFL then Color.RED else Color.WHITE);

def XLVC = close(XLV, period = AggregationPeriod.DAY);
def XLVH =  high(XLV, period = AggregationPeriod.DAY)[1];
def XLVL = low(XLV, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLV", if XLVC>XLVH then Color.GREEN else if XLVC < XLVL then Color.RED else Color.WHITE);


def XLIC = close(XLI, period = AggregationPeriod.DAY);
def XLIH =  high(XLI, period = AggregationPeriod.DAY)[1];
def XLIL = low(XLI, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLI", if XLIC>XLIH then Color.GREEN else if XLIC < XLIL then Color.RED else Color.WHITE);


def XLREC = close(XLRE, period = AggregationPeriod.DAY);
def XLREH =  high(XLRE, period = AggregationPeriod.DAY)[1];
def XLREL = low(XLRE, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLRE", if XLREC>XLREH then Color.GREEN else if XLREC < XLREL then Color.RED else Color.WHITE);


def XLKC = close(XLK, period = AggregationPeriod.DAY);
def XLKH =  high(XLK, period = AggregationPeriod.DAY)[1];
def XLKL = low(XLK, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLK", if XLKC>XLKH then Color.GREEN else if XLKC < XLKL then Color.RED else Color.WHITE);


def XLBC = close(XLB, period = AggregationPeriod.DAY);
def XLBH =  high(XLB, period = AggregationPeriod.DAY)[1];
def XLBL = low(XLB, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLB", if XLBC>XLBH then Color.GREEN else if XLBC < XLBL then Color.RED else Color.WHITE);


def XLUC = close(XLU, period = AggregationPeriod.DAY);
def XLUH =  high(XLU, period = AggregationPeriod.DAY)[1];
def XLUL = low(XLU, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLU", if XLUC>XLUH then Color.GREEN else if XLUC < XLUL then Color.RED else Color.WHITE);


def SNPC = close(SNP, period = AggregationPeriod.DAY);
def SNPH =  high(SNP, period = AggregationPeriod.DAY)[1];
def SNPL =  low(SNP, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"SPY", if SNPC>SNPH then Color.GREEN else if SNPC < SNPL then Color.RED else Color.WHITE);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hi @AlexsOptions,

Thanks for sharing...

I've taken the liberty to add a couple more that I had:

IBB = Biotechnology
XHB = Homebuilders
XPH = Pharmaceuticals
XRT = Retail
XSD = Semiconductors
XTN = Transportation

sector-summary.jpg


Code:
# START STUDY
# Sector Summary v2.1
# AlexsOptions, 5/22/2021

declare upper;

input DIA = "DIA";
input SNP = "SPY";
input QQQ = "QQQ";
input IWM = "IWM";
input IBB = "IBB";
input XHB = "XHB";
input XLB = "XLB";
input XLC = "XLC";
input XLE = "XLE";
input XLF = "XLF";
input XLI = "XLI";
input XLK = "XLK";
input XLP = "XLP";
input XLRE = "XLRE";
input XLU = "XLU";
input XLV = "XLV";
input XLY = "XLY";
input XPH = "XPH";
input XRT = "XRT";
input XSD = "XSD";
input XTN = "XTN";

# DOW 30
def DIAC = close(DIA, period = AggregationPeriod.DAY);
def DIAH =  high(DIA, period = AggregationPeriod.DAY)[1];
def DIAL = low(DIA, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"DIA", if DIAC > DIAH then Color.GREEN else if DIAC < DIAL then Color.RED else Color.WHITE);

# S&P 500
def SNPC = close(SNP, period = AggregationPeriod.DAY);
def SNPH =  high(SNP, period = AggregationPeriod.DAY)[1];
def SNPL =  low(SNP, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"SPY", if SNPC > SNPH then Color.GREEN else if SNPC < SNPL then Color.RED else Color.WHITE);

# NASDAQ 100
def QQQC = close(QQQ, period = AggregationPeriod.DAY);
def QQQH =  high(QQQ, period = AggregationPeriod.DAY)[1];
def QQQL = low(QQQ, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"QQQ", if QQQC > QQQH then Color.GREEN else if QQQC < QQQL then Color.RED else Color.WHITE);

# RUSSELL 2000
def IWMC = close(IWM, period = AggregationPeriod.DAY);
def IWMH =  high(IWM, period = AggregationPeriod.DAY)[1];
def IWML = low(IWM, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"IWM", if IWMC > IWMH then Color.GREEN else if IWMC < IWML then Color.RED else Color.WHITE);

# Biotechnology
def IBBC = close(IBB, period = AggregationPeriod.DAY);
def IBBH =  high(IBB, period = AggregationPeriod.DAY)[1];
def IBBL = low(IBB, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"IBB", if IBBC > IBBH then Color.GREEN else if IBBC < IBBL then Color.RED else Color.WHITE);

# Homebuilders
def XHBC = close(XHB, period = AggregationPeriod.DAY);
def XHBH =  high(XHB, period = AggregationPeriod.DAY)[1];
def XHBL = low(XHB, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"", if XHBC > XHBH then Color.GREEN else if XHBC < XHBL then Color.RED else Color.WHITE);

# Materials
def XLBC = close(XLB, period = AggregationPeriod.DAY);
def XLBH =  high(XLB, period = AggregationPeriod.DAY)[1];
def XLBL = low(XLB, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLB", if XLBC > XLBH then Color.GREEN else if XLBC < XLBL then Color.RED else Color.WHITE);

# Communications
def XLCC = close(XLC, period = AggregationPeriod.DAY);
def XLCH =  high(XLC, period = AggregationPeriod.DAY)[1];
def XLCL = low(XLC, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLC", if XLCC > XLCH then Color.GREEN else if XLCC < XLCL then Color.RED else Color.WHITE);

#Energy
def XLEC = close(XLE, period = AggregationPeriod.DAY);
def XLEH =  high(XLE, period = AggregationPeriod.DAY)[1];
def XLEL = low(XLE, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLE", if XLEC > XLEH then Color.GREEN else if XLEC < XLEL then Color.RED else Color.WHITE);

# Financials
def XLFC = close(XLF, period = AggregationPeriod.DAY);
def XLFH =  high(XLF, period = AggregationPeriod.DAY)[1];
def XLFL = low(XLF, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLF", if XLFC > XLFH then Color.GREEN else if XLFC < XLFL then Color.RED else Color.WHITE);

# Industrials
def XLIC = close(XLI, period = AggregationPeriod.DAY);
def XLIH =  high(XLI, period = AggregationPeriod.DAY)[1];
def XLIL = low(XLI, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLI", if XLIC > XLIH then Color.GREEN else if XLIC < XLIL then Color.RED else Color.WHITE);

# Technology
def XLKC = close(XLK, period = AggregationPeriod.DAY);
def XLKH =  high(XLK, period = AggregationPeriod.DAY)[1];
def XLKL = low(XLK, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLK", if XLKC > XLKH then Color.GREEN else if XLKC < XLKL then Color.RED else Color.WHITE);

# Consumer Staples
def XLPC = close(XLP, period = AggregationPeriod.DAY);
def XLPH =  high(XLP, period = AggregationPeriod.DAY)[1];
def XLPL = low(XLP, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLP", if XLPC > XLPH then Color.GREEN else if XLPC < XLPL then Color.RED else Color.WHITE);

# Real Estate
def XLREC = close(XLRE, period = AggregationPeriod.DAY);
def XLREH =  high(XLRE, period = AggregationPeriod.DAY)[1];
def XLREL = low(XLRE, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLRE", if XLREC  >XLREH then Color.GREEN else if XLREC < XLREL then Color.RED else Color.WHITE);

# Utilities
def XLUC = close(XLU, period = AggregationPeriod.DAY);
def XLUH =  high(XLU, period = AggregationPeriod.DAY)[1];
def XLUL = low(XLU, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLU", if XLUC > XLUH then Color.GREEN else if XLUC < XLUL then Color.RED else Color.WHITE);

# Healthcare
def XLVC = close(XLV, period = AggregationPeriod.DAY);
def XLVH =  high(XLV, period = AggregationPeriod.DAY)[1];
def XLVL = low(XLV, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLV", if XLVC > XLVH then Color.GREEN else if XLVC < XLVL then Color.RED else Color.WHITE);

# Consumer Discretionary
def XLYC = close(XLY, period = AggregationPeriod.DAY);
def XLYH =  high(XLY, period = AggregationPeriod.DAY)[1];
def XLYL = low(XLY, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XLY", if XLYC > XLYH then Color.GREEN else if XLYC < XLYL then Color.RED else Color.WHITE);

# Pharmaceuticals
def XPHC = close(XPH, period = AggregationPeriod.DAY);
def XPHH =  high(XPH, period = AggregationPeriod.DAY)[1];
def XPHL = low(XPH, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XPH", if XPHC > XPHH then Color.GREEN else if XPHC < XPHL then Color.RED else Color.WHITE);

# Retail
def XRTC = close(XRT, period = AggregationPeriod.DAY);
def XRTH =  high(XRT, period = AggregationPeriod.DAY)[1];
def XRTL = low(XRT, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XRT", if XRTC > XRTH then Color.GREEN else if XRTC < XRTL then Color.RED else Color.WHITE);

# Semiconductors
def XSDC = close(XSD, period = AggregationPeriod.DAY);
def XSDH =  high(XSD, period = AggregationPeriod.DAY)[1];
def XSDL = low(XSD, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XSD", if XSDC > XSDH then Color.GREEN else if XSDC < XSDL then Color.RED else Color.WHITE);

# Transportation
def XTNC = close(XTN, period = AggregationPeriod.DAY);
def XTNH =  high(XTN, period = AggregationPeriod.DAY)[1];
def XTNL = low(XTN, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"XTN", if XTNC > XTNH then Color.GREEN else if XTNC < XTNL then Color.RED else Color.WHITE);

# END STUDY

HTH...

Good Luck and Good Trading...
 
any way you can combine the code so the v1 and v2 can be together? im trying to edit the code to make it happen but it wont come out right.
 
any way you can combine the code so the v1 and v2 can be together? im trying to edit the code to make it happen but it wont come out right.
Code:
# START STUDY
# Sector Summary v2.1
# AlexsOptions, 5/22/2021

declare upper;

input DIA = "DIA";
input SNP = "/ES";
input QQQ = "/NQ";
input IWM = "IWM";
input IBB = "IBB";
input XHB = "XHB";
input XLB = "XLB";
input XLC = "XLC";
input XLE = "XLE";
input XLF = "XLF";
input XLI = "XLI";
input XLK = "XLK";
input XLP = "XLP";
input XLRE = "XLRE";
input XLU = "XLU";
input XLV = "XLV";
input XLY = "XLY";
input XPH = "XPH";
input XRT = "XRT";
input XSD = "XSD";
input XTN = "XTN";

# DOW 30
def DIAC = close(DIA, period = AggregationPeriod.DAY);
def DIAH =  high(DIA, period = AggregationPeriod.DAY)[1];
def DIAL = low(DIA, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"DOW: DIA", if DIAC > DIAH then Color.GREEN else if DIAC < DIAL then Color.RED else Color.WHITE);

# S&P 500
def SNPC = close(SNP, period = AggregationPeriod.DAY);
def SNPH =  high(SNP, period = AggregationPeriod.DAY)[1];
def SNPL =  low(SNP, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"SPY", if SNPC > SNPH then Color.GREEN else if SNPC < SNPL then Color.RED else Color.WHITE);

# NASDAQ 100
def QQQC = close(QQQ, period = AggregationPeriod.DAY);
def QQQH =  high(QQQ, period = AggregationPeriod.DAY)[1];
def QQQL = low(QQQ, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"NASDAQ /NQ", if QQQC > QQQH then Color.GREEN else if QQQC < QQQL then Color.RED else Color.WHITE);

# RUSSELL 2000
def IWMC = close(IWM, period = AggregationPeriod.DAY);
def IWMH =  high(IWM, period = AggregationPeriod.DAY)[1];
def IWML = low(IWM, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"RUSSELL: IWM", if IWMC > IWMH then Color.GREEN else if IWMC < IWML then Color.RED else Color.WHITE);

# Biotechnology
def IBBC = close(IBB, period = AggregationPeriod.DAY);
def IBBH =  high(IBB, period = AggregationPeriod.DAY)[1];
def IBBL = low(IBB, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"# Bio: IBB", if IBBC > IBBH then Color.GREEN else if IBBC < IBBL then Color.RED else Color.WHITE);

# Homebuilders
def XHBC = close(XHB, period = AggregationPeriod.DAY);
def XHBH =  high(XHB, period = AggregationPeriod.DAY)[1];
def XHBL = low(XHB, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Homebuilders: XHB", if XHBC > XHBH then Color.GREEN else if XHBC < XHBL then Color.RED else Color.WHITE);

# Materials
def XLBC = close(XLB, period = AggregationPeriod.DAY);
def XLBH =  high(XLB, period = AggregationPeriod.DAY)[1];
def XLBL = low(XLB, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Materials: XLB", if XLBC > XLBH then Color.GREEN else if XLBC < XLBL then Color.RED else Color.WHITE);

# Communications
def XLCC = close(XLC, period = AggregationPeriod.DAY);
def XLCH =  high(XLC, period = AggregationPeriod.DAY)[1];
def XLCL = low(XLC, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Communications: XLC", if XLCC > XLCH then Color.GREEN else if XLCC < XLCL then Color.RED else Color.WHITE);

#Energy
def XLEC = close(XLE, period = AggregationPeriod.DAY);
def XLEH =  high(XLE, period = AggregationPeriod.DAY)[1];
def XLEL = low(XLE, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Energy: XLE", if XLEC > XLEH then Color.GREEN else if XLEC < XLEL then Color.RED else Color.WHITE);

# Financials
def XLFC = close(XLF, period = AggregationPeriod.DAY);
def XLFH =  high(XLF, period = AggregationPeriod.DAY)[1];
def XLFL = low(XLF, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Financials: XLF", if XLFC > XLFH then Color.GREEN else if XLFC < XLFL then Color.RED else Color.WHITE);

# Industrials
def XLIC = close(XLI, period = AggregationPeriod.DAY);
def XLIH =  high(XLI, period = AggregationPeriod.DAY)[1];
def XLIL = low(XLI, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Industrials: XLI", if XLIC > XLIH then Color.GREEN else if XLIC < XLIL then Color.RED else Color.WHITE);

# Technology
def XLKC = close(XLK, period = AggregationPeriod.DAY);
def XLKH =  high(XLK, period = AggregationPeriod.DAY)[1];
def XLKL = low(XLK, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Tech: XLK", if XLKC > XLKH then Color.GREEN else if XLKC < XLKL then Color.RED else Color.WHITE);

# Consumer Staples
def XLPC = close(XLP, period = AggregationPeriod.DAY);
def XLPH =  high(XLP, period = AggregationPeriod.DAY)[1];
def XLPL = low(XLP, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Staples: XLP", if XLPC > XLPH then Color.GREEN else if XLPC < XLPL then Color.RED else Color.WHITE);

# Real Estate
def XLREC = close(XLRE, period = AggregationPeriod.DAY);
def XLREH =  high(XLRE, period = AggregationPeriod.DAY)[1];
def XLREL = low(XLRE, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Real: XLRE", if XLREC  >XLREH then Color.GREEN else if XLREC < XLREL then Color.RED else Color.WHITE);

# Utilities
def XLUC = close(XLU, period = AggregationPeriod.DAY);
def XLUH =  high(XLU, period = AggregationPeriod.DAY)[1];
def XLUL = low(XLU, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Utilities: XLU", if XLUC > XLUH then Color.GREEN else if XLUC < XLUL then Color.RED else Color.WHITE);

# Healthcare
def XLVC = close(XLV, period = AggregationPeriod.DAY);
def XLVH =  high(XLV, period = AggregationPeriod.DAY)[1];
def XLVL = low(XLV, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Healthcare: XLV", if XLVC > XLVH then Color.GREEN else if XLVC < XLVL then Color.RED else Color.WHITE);

# Consumer Discretionary
def XLYC = close(XLY, period = AggregationPeriod.DAY);
def XLYH =  high(XLY, period = AggregationPeriod.DAY)[1];
def XLYL = low(XLY, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Discretionary: XLY", if XLYC > XLYH then Color.GREEN else if XLYC < XLYL then Color.RED else Color.WHITE);

# Pharmaceuticals
def XPHC = close(XPH, period = AggregationPeriod.DAY);
def XPHH =  high(XPH, period = AggregationPeriod.DAY)[1];
def XPHL = low(XPH, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Pharmaceuticals: XPH", if XPHC > XPHH then Color.GREEN else if XPHC < XPHL then Color.RED else Color.WHITE);

# Retail
def XRTC = close(XRT, period = AggregationPeriod.DAY);
def XRTH =  high(XRT, period = AggregationPeriod.DAY)[1];
def XRTL = low(XRT, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Retail :XRT", if XRTC > XRTH then Color.GREEN else if XRTC < XRTL then Color.RED else Color.WHITE);

# Semiconductors
def XSDC = close(XSD, period = AggregationPeriod.DAY);
def XSDH =  high(XSD, period = AggregationPeriod.DAY)[1];
def XSDL = low(XSD, period = AggregationPeriod.DAY)[1];
AddLabel(yes,"Semiconductors :XSD", if XSDC > XSDH then Color.GREEN else if XSDC < XSDL then Color.RED else Color.WHITE);

# Transportation
def XTNC = close(XTN, period = AggregationPeriod.DAY);
def XTNH =  high(XTN, period = AggregationPeriod.DAY)[1];
def XTNL = low(XTN, period = AggregationPeriod.DAY)[1];
AddLabel(yes," Transportation: XTN", if XTNC > XTNH then Color.GREEN else if XTNC < XTNL then Color.RED else Color.WHITE);

# END STUDY
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
500 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top