The following script places a label stating the % of the 11 S&P sectors currently above the VWAP
It is only accurate when I display it on a daily chart, I wish I could make it appear as a constant no matter what TF my current chart is.
Possible?
Additionally, does anyone know how I could automatically replace this list of 11 sectors with a list of the 500 companies in the S&P, ie a program to re-write the code using the same format.
Also. any improvements on this code are appreciated.
It is only accurate when I display it on a daily chart, I wish I could make it appear as a constant no matter what TF my current chart is.
Possible?
Additionally, does anyone know how I could automatically replace this list of 11 sectors with a list of the 500 companies in the S&P, ie a program to re-write the code using the same format.
Also. any improvements on this code are appreciated.
Code:
input XLE = "XLE";
input XLU = "XLU";
input XLRE = "XLRE";
input XLB = "XLB";
input XLP = "XLP";
input XLV = "XLV";
input XLI = "XLI";
input XLF = "XLF";
input XLY = "XLY";
input XLK = "XLK";
input XLC = "XLC";
input NumberofTickers = 11;
def condition1 = close(symbol = XLE) > VWAP(symbol = XLE);
def condition2 = close(symbol = XLU) > VWAP(symbol = XLU);
def condition3 = close(symbol = XLRE) > VWAP(symbol = XLRE);
def condition4 = close(symbol = XLB) > VWAP(symbol = XLB);
def condition5 = close(symbol = XLP) > VWAP(symbol = XLP);
def condition6 = close(symbol = XLV) > VWAP(symbol = XLV);
def condition7 = close(symbol = XLI) > VWAP(symbol = XLI);
def condition8 = close(symbol = XLF) > VWAP(symbol = XLF);
def condition9 = close(symbol = XLY) > VWAP(symbol = XLY);
def condition10 = close(symbol = XLK) > VWAP(symbol = XLK);
def condition11 = close(symbol = XLC) > VWAP(symbol = XLC);
def conditionCount = condition1 + condition2 +condition3+condition4+condition5+condition6+condition7+ condition8+condition9+condition10+condition11;
def percentabove = (conditionCount / NumberofTickers)*100;
AddLabel(visible = Yes, text = "% of S&P Sectors above VWAP: " + percentabove + "%");