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.
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...
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.
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.
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
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.
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.