Format Watchlist Text In ThinkOrSwim

Buckbull

Active member
How would I change the color of the text To Black what do I have to change or add ? Thank You

Code:
# creates custom watch list column that says "bullish" in green when both price > 50sma AND 50sma > 200sma
# or that says "bearish" in red when both price < 50sma AND 50sma < 200sma

# note the two risky or uncertain times are currently blank cells, both critera have been defined so that risky50over200 and risky200over50 could be used to create labels and/or color-coding for those conditions as well (via editing the AddLabel and/or the AssignBackgroundColor lines of code)

def x = SimpleMovingAvg("length" = 50);
def y = SimpleMovingAvg("length" = 200);

def risky50over200 = x > y AND close < x;
def risky200over50 = x < y AND close > x;

def bullish = close > x AND x > y;
def bearish = close < x AND x < y;

AddLabel (yes, if bearish then "bearish  " else if bullish then "bullish  " else " ");

AssignBackgroundColor (if bearish then color.RED else if bullish then color.GREEN else color.LIGHT_GRAY);
 
Last edited by a moderator:
@Buckbull To change the text to black, just replace your AddLabel statement with the following

Code:
AddLabel (yes, if bearish then "bearish " else if bullish then "bullish " else " ", Color.BLACK);
 
@tomsk Could I trouble for one more thing ? If possible How would I add Average Daily Volume to this

Code:
#HINT: This study plots a chart label for Net Change and Percent Change from prior day's (regardless of time period of the chart). \n\n Label color is red if today's price is lower than yesterday's close.  \n\n And label color is green if today's price is higher than yesterday's close.  \n\n Label color is gray if today's price is identcal to yesterday's close.

input show_label = yes;
input show_bubble = no;


def period_Type = AggregationPeriod.DAY;

def begin = close(period = period_Type)[1];
def end = close(period = period_Type);
def NetChg = end - begin;
def PctChg = (end / begin) - 1;
def DayVolume =  volume(period = "DAY");

AddLabel(show_label, "Last: " + close + "  " + "Net Change:  " + AsDollars(NetChg) + "  " + "Percent Change: " + AsPercent(PctChg) + "  " + "Total Volume for the Day:  " + DayVolume , if NetChg > 0 then Color.GREEN else if NetChg < 0 then Color.RED else Color.LIGHT_GRAY);


def bar = if IsNaN(close)
             then if yes
                     then bar[1]
                     else Double.NaN
             else BarNumber();
def ThisBar = HighestAll(bar);
def barCount   = if bar == ThisBar
                 then close
                 else Double.NaN;

AddChartBubble(if show_bubble and bar == ThisBar then yes else no, if NetChg > 0 then high * 1.10 else low * 0.90, " Last: " + close + "  " + "\n Net Change:  " + AsDollars(NetChg) + "  " + "\n Percent Change: " + AsPercent(PctChg), if NetChg > 0 then Color.GREEN else if NetChg < 0 then Color.RED else Color.LIGHT_GRAY,  if NetChg > 0 then yes else no) ;
 
Last edited by a moderator:
@Buckbull Sure, I have added the average daily volume over 20 days in the label. You can adjust the number of periods you wish via the input variable "periods_AvgDailyVolume" via the user interface

Code:
#HINT: This study plots a chart label for Net Change and Percent Change from prior day's (regardless of time period of the chart). \n\n Label color is red if today's price is lower than yesterday's close.  \n\n And label color is green if today's price is higher than yesterday's close.  \n\n Label color is gray if today's price is identcal to yesterday's close.

input show_label = yes;
input show_bubble = no;
input periods_AvgDailyVolume = 20;

def period_Type = AggregationPeriod.DAY;

def begin = close(period = period_Type)[1];
def end = close(period = period_Type);
def NetChg = end - begin;
def PctChg = (end / begin) - 1;
def DayVolume =  volume(period = "DAY");
def AvgDailyVolume = Average(DayVolume, periods_AvgDailyVolume);

AddLabel(show_label, "Last: " + close + "  " + "Net Change:  " + AsDollars(NetChg) + "  " + "Percent Change: " + AsPercent(PctChg) + "  " + "Total Volume for the Day:  " + DayVolume + " Average Daily Volume: " + AvgDailyVolume, if NetChg > 0 then Color.GREEN else if NetChg < 0 then Color.RED else Color.LIGHT_GRAY);

def bar = if IsNaN(close)
             then if yes
                     then bar[1]
                     else Double.NaN
             else BarNumber();
def ThisBar = HighestAll(bar);
def barCount   = if bar == ThisBar
                 then close
                 else Double.NaN;

AddChartBubble(if show_bubble and bar == ThisBar then yes else no, if NetChg > 0 then high * 1.10 else low * 0.90, " Last: " + close + "  " + "\n Net Change:  " + AsDollars(NetChg) + "  " + "\n Percent Change: " + AsPercent(PctChg), if NetChg > 0 then Color.GREEN else if NetChg < 0 then Color.RED else Color.LIGHT_GRAY,  if NetChg > 0 then yes else no) ;
 
Is there a way to make a color adjustable using an input variable. I've tried searching but I can only find it for plots. Like lets say I have multiple Labels and I want a global color selection. Thanks in advance
 
@Wannaspeed There absolutely is a slick way to implement this. Here's an example using an example I just pieced together for you to illustrate this. All you need to do is adjust the color direct from the user interface

Code:
# Recent High with User Selectable Colors
# tomsk
# 11.25.2019

input LabelColor = {default "MAGENTA", "CYAN", "PINK", "LIGHT_GRAY", "ORANGE", "RED", "GREEN", "GRAY", "WHITE"};

def cond = close > close[1];
def bar = if cond then BarNumber() else bar[1];

plot data = if barNumber() >= HighestAll(bar) and cond then high else Double.NaN;
     data.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
     data.SetLineWeight (5);
     data.SetDefaultColor(GetColor(LabelColor));
# End Recent High with User Selectable Colors
 
After much trial and error I got it! You can see my various mistakes in the comment out areas of the code.
Code:
#LABEL COLOR TEST
input LabelColor = {default "MAGENTA", "CYAN", "PINK", "LIGHT_GRAY", "ORANGE", "RED", "GREEN", "GRAY", "WHITE"};

def dollarvol = VWAP* volume;
#labelColor (yes, dollarvol);
Addlabel (yes, dollarvol,getColor(labelColor));
#dollarvol.SetDefaultColor(GetColor(LabelColor));
 
So i have a study which has chart labels but there is no color code when i checked the source. Can anyone help me show what i need to add to the line of code so that i can change the color myself to whatever i want?

This is the line,

AddLabel(showlabels, LEVEL_1 + "%= " + Round(level1, 2));
 
So i have a study which has chart labels but there is no color code when i checked the source. Can anyone help me show what i need to add to the line of code so that i can change the color myself to whatever i want?

This is the line,
What are you trying to show? Are you looking for one color or multi color?

This is one color.

AddLabel(showlabels, LEVEL_1 + "%= " + Round(level1, 2), color.CYAN);
 
What are you trying to show? Are you looking for one color or multi color?

This is one color.

AddLabel(showlabels, LEVEL_1 + "%= " + Round(level1, 2), color.CYAN);

I just want the ability to change the color myself using these codes here

Edit: Ok, thanks. I will try and add just like you did in your example.
 
@zeek Here is an example on how to have different colors in your label depending on the value of level1

Code:
AddLabel(showlabels, LEVEL_1 + "%= " + Round(level1, 2),
    if level1 > 80 then Color.Green else if level1 < 40 then Color.Red else Color.Yellow);

You can replace the color with RGB definitions as found in the link you posted, so instead of Color.Green you would have
CreateColor(50,150,250) as an example
 
  • Like
Reactions: JCN
I have tried this and indeed it does change the color but it is not the color requested. Any suggestions? This is code for the Coppock indicator. I would like to change the color of the zero line when I configure the indicator.
Code:
#
#Coppock Indicator
#
declare lower;

input RateOfChangeSlowPeriod = 14;
input RateOfChangeFastPeriod = 11;
input WeightedMAPeriod = 10;
input ZeroLineColor = {default "BLACK" , "WHITE" , "GREEN"};

def AggregationPeriod = if (GetAggregationPeriod() < AggregationPeriod.WEEK) then AggregationPeriod.WEEK else GetAggregationPeriod();

def price = close(period = AggregationPeriod);

def ROC1 = if price[RateOfChangeSlowPeriod] != 0 then (price / price[RateOfChangeSlowPeriod] - 1) * 100 else 0;
def ROC2 = if price[RateOfChangeFastPeriod] != 0 then (price / price[RateOfChangeFastPeriod] - 1) * 100 else 0;

plot Coppock = WMA(ROC1 + ROC2, WeightedMAPeriod);
    Coppock.AssignValueColor(if Coppock > Coppock[1] then Color.GREEN else Color.RED);
    Coppock.SetDefaultColor(GetColor(1));
    Coppock.SetLineWeight(2);
    Coppock.HideBubble();

plot ZeroLine = 0;
    ZeroLine.SetDefaultColor(GetColor(ZeroLineColor));
    ZeroLine.HideBubble();

AddChartBubble(Coppock[1] < 0 and Coppock > Coppock[1] and Coppock[1] < Coppock[2], Coppock, "Buy", Color.CYAN, no);
 
Delete following 2 lines:

Code:
input ZeroLineColor = {default "WHITE" , "GREEN"};
ZeroLine.SetDefaultColor(GetColor(ZeroLineColor));

Add this line and put in color of your choice if do not want white.

Code:
ZeroLine.SetDefaultColor(Color.WHITE);
 
That does not allow me to configure the color without having to edit the code. If I have a black zero line and change the background to black it does not show up. Also, If I share the indicator with someone else I do not know what background they are using. This also gives me the freedom to change colors on other indicators If I know how to do it.
 
Is there anyway you can input a value on a chart label without going to the study setup??
Edited: You can select Text Note from the Tools menu... Select the "T" symbol from the Drawing Set to make it your Active Tool... Right Click where you want the upper left corner of the note and select Add Drawing... Select "T" again and a popup box will appear... Type in the text you want to display and press Ok...
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
293 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

What are the benefits of VIP Membership?
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.
Back
Top