Ok so if this is my current column code:
Code:
def date = getMonth();
def JanFirstClose = fold counter2 = 0 to 25 while date == Date[counter2] do close[counter2];
Plot YTDReturn = ((close/janFirstClose)-1)*100;
AssignBackgroundColor(if YTDReturn > 0 then color.GRAY else color.Red);
1. How would I use it with addLabel()?
I got it working with plot.assignValueColor but Im curious as to the other one.
2. Also, how can I apply this to the Monitor Tab > P/L Open and P/L Day? I've always wanted to make those numbers show up green for profit and red for loss.
Thanks
column studies
i don't think you can change built in columns , Monitor Tab > P/L Open and P/L Day. i think you would have to create a study to do those calculations, then format the output.
adding a setdefaultcolor parameter to your code, changes the font color to black
Code:
def date = getMonth();
def JanFirstClose = fold counter2 = 0 to 25 while date == Date[counter2] do close[counter2];
Plot YTDReturn = ((close/janFirstClose)-1)*100;
AssignBackgroundColor(if YTDReturn > 0 then color.GRAY else color.Red);
ytdreturn.setdefaultcolor(color.black);
in the version below, i disabled your plot and added a addlabel().
using addlabel, allows combining numbers and text. i added a % symbol after the number.
if your data is only numbers, you will want to stick with plot, so the numbers sort correctly.
i start all my custom column studies with a z, so they group together at the end of the list
Code:
# zfontc_03
# https://usethinkscript.com/threads/change-color-of-text-on-watchlist.9757/#post-88021
def date = getMonth();
def JanFirstClose = fold counter2 = 0 to 25 while date == Date[counter2] do close[counter2];
# change plot to def
def YTDReturn = ((close/janFirstClose)-1)*100;
#Plot YTDReturn = ((close/janFirstClose)-1)*100;
#ytdreturn.setdefaultcolor(color.black);
AssignBackgroundColor(if YTDReturn > 0 then color.GRAY else color.Red);
# add addlabel for output.
# this will sort as text, not numbers, by the first character not the number value.
addlabel(1, YTDReturn, color.black);
#
the above study, with addlabel,
study added to marketwatch , column
. top right, gear icon in header, customize