krahsloop
Member
Hi all, I'm using the watchlist code below (from the original post here) and it appears to calculate from yesterday's close:
Would someone be able to help me modify the code to calculate from the open instead, i.e. "difference in % change from open"? I use a simple code to calculate change from open on my watchlist right now:
Just trying to figure out how to combine these two scripts basically. So for example, if SPX is currently up 1% from the open, and AMZN is up 4% from the open, the watchlist column would show 3%. Thanks everyone!
Ruby:
# Difference in Percent Change vs SPX
# Select your choice of timeframe above
# current symbol change
def a = (close-close[1])/close[1];
# SPX change
def sym = close("SPX");
def b = (sym-sym[1])/sym[1];
# current symbol change minus SPX change
def c = a-b;
# gives the difference as a percent value
AddLabel(1,AsPercent(c),
if c > 0 then createcolor(0,204,75)
else if c == 0 then color.light_gray
else createcolor(250,90,0));
Would someone be able to help me modify the code to calculate from the open instead, i.e. "difference in % change from open"? I use a simple code to calculate change from open on my watchlist right now:
Ruby:
def ChangefromOpen = close / open - 1;
Just trying to figure out how to combine these two scripts basically. So for example, if SPX is currently up 1% from the open, and AMZN is up 4% from the open, the watchlist column would show 3%. Thanks everyone!