Help with a daily high low watchlist column

Nicksmo

New member
VIP
I'm trying to make a watchlist column display things better....right now it is spitting out this...the red background shows how much the current price is below the previous bar on the daily....the green shows how much it is above the previous days price....the yellow is still an "inside bar" and I made that a calculation of the percentage inside the last bar....so for instance the first yellow "44.9" is 44.9% up the bar...meaning pretty much the current price on the day is sitting around 44.9 percent of the way up the bar....I wanted to change the text to make the yellow when its inside be different as it gets a bit confusing...but also wanted to add "%' next to it...or if there was a better way to display this i would be great too...

so I wanted to change the inside bar values to percentage and perhaps be able to change the colors of the values

r6iEG8Y.png


Code:
def HiBroke = If (close > high[1] ,1,0);
def LoBroke = If (close  < low[1] ,1,0);
def BothBroke = If (HiBroke && LoBroke, 1,0);
def HiBrokeAmt = If HiBroke then (close - high[1] ) else double.nan;
def LoBrokeAmt = If LoBroke then (low[1] - close) else double.nan;
def inside = if (close < high [1] and close > low [1], 1,0);
def toptobottom = high[1] - low [1];
def insidevalue = close - low[1] ;
def insideper  = (round(((insidevalue/toptobottom)*100),1));


Addlabel(1,  if HiBroke && !LoBroke then round(HiBrokeAmt,2)
else if !HiBroke && LoBroke then round(LoBrokeAmt,2)
else  if HiBroke && LoBroke then  round(HiBrokeAmt,2)
else if inside then insideper
else 0, color.YELLOW);

AssignBackgroundColor(if HiBroke then color.Dark_green
else if LoBroke then color.Light_red
else if HiBroke && LoBroke then color.pink
else color.current);
 

Nicksmo

New member
VIP
@Nicksmo You said:

I say: add +"%" after each variable in your label. NOTE: this column will not be sortable after this change.

You said:

I say: sounds great, go in your watchlist and change the colors. your choices are:
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/Color
I have tried adding + “%” and it returns and error in the code.

min terms of the color i would like the “yellow” text with no red or green background to be gray and everything else the same
 

rad14733

Well-known member
VIP
@Nicksmo Try the following for the added "%"... It should work... I do concatenation all the time for labels...

Ruby:
Addlabel(1,  if HiBroke && !LoBroke then round(HiBrokeAmt,2) + "%"
else if !HiBroke && LoBroke then round(LoBrokeAmt,2) + "%"
else  if HiBroke && LoBroke then  round(HiBrokeAmt,2) + "%"
else if inside then insideper + "%"
else 0 + "%", color.YELLOW);
 

Similar threads

Top