# Adding Color to Plots, Labels, & Watchlists In ThinkOrSwim

#### MerryDay

Staff member
Staff
VIP
Adding Color to Plots and Labels
A frequent request is for coloring plots, labels, watch lists: green for upticks, red for down.
This example can be applied to a plot of any type of oscillator.

Ruby:
``````# TOS RSI
declare lower ;
input show_label = yes ;
input price = close ;
input OB = 75 ;
input OS = 35 ;
input rsi_length = 14 ;
# ########################################################
#Using GlobalColors makes the colors modifiable
DefineGlobalColor("maxxed", CreateColor(50, 200, 255)) ;
DefineGlobalColor("rising",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("bear",  CreateColor(225, 0, 0)) ;
DefineGlobalColor("pretrend", CreateColor (200, 125, 255)) ;
# ########################################################

Plot RSI = reference RSI("price" = PRICE, "length" = rsi_length);
# ########################################################
#RSI> RSI[1] this statement is saying if the current candle is greater than the previous candle
#that is what [1] denotes. Thus defining uptick. The same is then done for downticks.
RSI.AssignValueColor(
if RSI> OB then GlobalColor("maxxed") else
if RSI< OS then GlobalColor("pretrend") else
if RSI> RSI[1] then GlobalColor("rising")
else GlobalColor("bear"));
RSI.SetLineWeight(3);
# ########################################################

plot OverBought = OB;
plot OverSold = OS;
plot UpArrow = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownArrow = if RSI crosses below OverBought then OverBought else Double.NaN;

DefineGlobalColor("OBcolor", CreateColor(171, 171, 225)) ;
DefineGlobalColor("OScolor", CreateColor(220, 220, 128)) ;
OverBought.SetDefaultColor(GlobalColor("OBcolor"));
OverSold.SetDefaultColor(GlobalColor("OScolor"));
UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpArrow.SetDefaultColor(color.dark_green);
DownArrow.SetDefaultColor(color.dark_red);
# ########################################################
# The same logic that was used in coloring the plot can be used in labels
if RSI> OB then "RSI maxxed" else
if RSI< OS then "RSI pre-trend" else
if RSI> RSI[1] then "RSI Trending " +round(RSI,2)
else "RSI Bear " +round(RSI,2) ,
if RSI> OB then GlobalColor("maxxed") else
if RSI< OS and RSI>RSI[1] then GlobalColor("pretrend") else
if RSI> RSI[1] then GlobalColor("rising")
else GlobalColor("bear"));
AddCloud(if RSI >= OB then RSI else Double.NaN, OB,
GlobalColor("maxxed"), GlobalColor("maxxed"));
AddCloud(if RSI <= OS then OS else Double.NaN, RSI,
GlobalColor("pretrend"), GlobalColor("pretrend"));
# ########################################################``````

Last edited:
Here is another example, a poster requested a Schaff watchlist

Chart & Labels
Ruby:
``````# TOS Schaff Cycle
declare lower ;
input show_label = yes ;
input OB = 80 ;
input OS = 20 ;
# ########################################################
#Using GlobalColors makes the colors modifiable
DefineGlobalColor("maxxed", CreateColor(0, 70, 30)) ;
DefineGlobalColor("rising",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("bear",  CreateColor(225, 0, 0)) ;
DefineGlobalColor("begin", CreateColor(50, 200, 255)) ;
DefineGlobalColor("zero", CreateColor (200, 125, 255)) ;
# ########################################################
Plot Schaff  = SchaffTrendCycle()."STC" ;
# ########################################################
#Schaff> Schaff[1] this statement is saying if the current candle is greater than the previous candle
#that is what [1] denotes. Thus defining uptick. The same is then done for downticks.
Schaff.AssignValueColor(
if Schaff> OB then GlobalColor("maxxed") else
if Schaff< OS and Schaff< Schaff[1] then GlobalColor("zero") else
if Schaff< OS and Schaff> Schaff[1] then GlobalColor("begin") else
if Schaff> Schaff[1] then GlobalColor("rising")
else GlobalColor("bear"));
Schaff.SetLineWeight(3);
# ########################################################

plot OverBought = OB;
plot OverSold = OS;
plot UpArrow = if Schaff crosses above OverSold then OverSold else Double.NaN;
plot DownArrow = if Schaff crosses below OverBought then OverBought else Double.NaN;

DefineGlobalColor("OBcolor", CreateColor(171, 171, 225)) ;
DefineGlobalColor("OScolor", CreateColor(220, 220, 128)) ;
OverBought.SetDefaultColor(GlobalColor("OBcolor"));
OverSold.SetDefaultColor(GlobalColor("OScolor"));
UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpArrow.SetDefaultColor(color.dark_green);
DownArrow.SetDefaultColor(color.dark_red);
# ########################################################
# The same logic that was used in coloring the plot can be used in labels
if Schaff> OB then "Schaff maxxed" else
if Schaff< OS and Schaff< Schaff[1] then "Schaff bottomed" else
if Schaff< OS and Schaff> Schaff[1] then "Schaff Trend BEGIN" else
if Schaff> Schaff[1] then "Schaff rising " +round(Schaff,2)
else "Schaff falling " +round(Schaff,2) ,
if Schaff> OB then GlobalColor("maxxed") else
if Schaff< OS and Schaff< Schaff[1] then GlobalColor("zero") else
if Schaff< OS and Schaff> Schaff[1] then GlobalColor("begin") else
if Schaff> Schaff[1] then GlobalColor("rising")
else GlobalColor("bear"));
AddCloud(if Schaff >= OB then Schaff else Double.NaN, OB,
GlobalColor("maxxed"), GlobalColor("maxxed"));
AddCloud(if Schaff <= OS then OS else Double.NaN, Schaff,
GlobalColor("zero"), GlobalColor("zero"));
# ########################################################``````
Watchlist #1:
Ruby:
``````# TOS Schaff Cycle
input OB = 80 ;
input OS = 20 ;
# ########################################################
Plot Schaff  = SchaffTrendCycle()."STC" ;
# ########################################################
AssignBackgroundColor(
if Schaff> OB then color.dark_green else
if Schaff< OS and Schaff>=Schaff[1] then CreateColor(50, 200, 255) else
if Schaff< OS then CreateColor (200, 125, 255) else
if Schaff> Schaff[1] then CreateColor(0, 165, 0)
else CreateColor(225, 0, 0));
# ########################################################``````
Watchlist #2
Ruby:
``````# TOS Schaff Cycle
input OB = 80 ;
input OS = 20 ;
# ########################################################
plot Schaff  = SchaffTrendCycle()."STC" ;
# ########################################################
if Schaff> OB then "maxxed" else
if Schaff< OS and Schaff< Schaff[1] then "bottomed" else
if Schaff< OS and Schaff> Schaff[1] then "Trend BEGIN" else
if Schaff> Schaff[1] then "rising "
else "falling" );
# ########################################################
AssignBackgroundColor(
if Schaff> OB then color.dark_green else
if Schaff< OS and Schaff>=Schaff[1] then CreateColor(50, 200, 255) else
if Schaff< OS then CreateColor (200, 125, 255) else
if Schaff> Schaff[1] then CreateColor(0, 165, 0)
else CreateColor(225, 0, 0));
# ########################################################``````

Last edited:
I was really wishing for a watch list column for Schaff, and was so happy to find what I thought was it in #post-66596 -- it looks exactly what I was looking for, but... I've never created a watch list column and I'm having trouble. I can't figure out which part of the code I should be using. I either get error messages, or when I finally seem to get it right, the watch list column gets stuck on "loading" -- can you show me how the code should look? Thanks so much!

Last edited by a moderator:
@NatalieHollis
There was a major update to the platform over the weekend. Weekend maintenance tends to make watchlists perform poorly
The watchlist columns are working fine for me. If you are still having issues come Monday morning, you could try loading them using shared links.

Shared Link Schaff Trend Cycle WatchList #1 = http://tos.mx/izV9n5i
Shared Link Schaff Trend Cycle WatchList #2 = http://tos.mx/w4GZ9nI

Last edited:
@MerryDay how can i change the colors to different ones? for example wanting to change the bottom or anything below 80 to red instead of purple and vise versa

@MerryDay how can i change the colors to different ones? for example wanting to change the bottom or anything below 80 to red instead of purple and vise versa
To Change the colors in a chart:
1. Click on the Edit Setting Gear​
2. Scroll to the bottom​
3. Change Global Colors​

Last edited:
@MerryDay there is no Edit Setting Gear for a custom column

Modify Color In A Watchlist Column:
if Schaff> OB then "maxxed" else
if Schaff< OS and Schaff< Schaff[1] then "bottomed" else
if Schaff< OS and Schaff> Schaff[1] then "Trend BEGIN" else
if Schaff> Schaff[1] then "rising "
else "falling" );
# ########################################################
AssignBackgroundColor(
if Schaff> OB then color.dark_green else
if Schaff< OS and Schaff>=Schaff[1] then CreateColor(50, 200, 255) else
if Schaff< OS then CreateColor (200, 125, 255) else
if Schaff> Schaff[1] then CreateColor(0, 165, 0)
else CreateColor(225, 0, 0));
Watchlist column fields color can be assigned using ToS standard colors:
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/Color
Or color can be created with the CreateColor function: CreateColor (200, 125, 255) .

The choices are endless.
Try changing each color in your watchlist, you will quickly figure out which line does what.

@MerryDay Im trying to color the Schaff green if its above 75 and red if its below 25, anything in the middle has no color, Im having trouble getting it this way any way you could help me?

Adding Color to Plots and Labels
A frequent request is for coloring plots, labels, watch lists: green for upticks, red for down.
This example can be applied to a plot of any type of oscillator.

Ruby:
``````# TOS RSI
declare lower ;
input show_label = yes ;
input price = close ;
input OB = 75 ;
input OS = 35 ;
input rsi_length = 14 ;
# ########################################################
#Using GlobalColors makes the colors modifiable
DefineGlobalColor("maxxed", CreateColor(50, 200, 255)) ;
DefineGlobalColor("rising",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("bear",  CreateColor(225, 0, 0)) ;
DefineGlobalColor("pretrend", CreateColor (200, 125, 255)) ;
# ########################################################

Plot RSI = reference RSI("price" = PRICE, "length" = rsi_length);
# ########################################################
#RSI> RSI[1] this statement is saying if the current candle is greater than the previous candle
#that is what [1] denotes. Thus defining uptick. The same is then done for downticks.
RSI.AssignValueColor(
if RSI> OB then GlobalColor("maxxed") else
if RSI< OS then GlobalColor("pretrend") else
if RSI> RSI[1] then GlobalColor("rising")
else GlobalColor("bear"));
RSI.SetLineWeight(3);
# ########################################################

plot OverBought = OB;
plot OverSold = OS;
plot UpArrow = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownArrow = if RSI crosses below OverBought then OverBought else Double.NaN;

DefineGlobalColor("OBcolor", CreateColor(171, 171, 225)) ;
DefineGlobalColor("OScolor", CreateColor(220, 220, 128)) ;
OverBought.SetDefaultColor(GlobalColor("OBcolor"));
OverSold.SetDefaultColor(GlobalColor("OScolor"));
UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpArrow.SetDefaultColor(color.dark_green);
DownArrow.SetDefaultColor(color.dark_red);
# ########################################################
# The same logic that was used in coloring the plot can be used in labels
if RSI> OB then "RSI maxxed" else
if RSI< OS then "RSI pre-trend" else
if RSI> RSI[1] then "RSI Trending " +round(RSI,2)
else "RSI Bear " +round(RSI,2) ,
if RSI> OB then GlobalColor("maxxed") else
if RSI< OS and RSI>RSI[1] then GlobalColor("pretrend") else
if RSI> RSI[1] then GlobalColor("rising")
else GlobalColor("bear"));
AddCloud(if RSI >= OB then RSI else Double.NaN, OB,
GlobalColor("maxxed"), GlobalColor("maxxed"));
AddCloud(if RSI <= OS then OS else Double.NaN, RSI,
GlobalColor("pretrend"), GlobalColor("pretrend"));
# ########################################################``````
Is it possible to
Adding Color to Plots and Labels
A frequent request is for coloring plots, labels, watch lists: green for upticks, red for down.
This example can be applied to a plot of any type of oscillator.

Ruby:
``````# TOS RSI
declare lower ;
input show_label = yes ;
input price = close ;
input OB = 75 ;
input OS = 35 ;
input rsi_length = 14 ;
# ########################################################
#Using GlobalColors makes the colors modifiable
DefineGlobalColor("maxxed", CreateColor(50, 200, 255)) ;
DefineGlobalColor("rising",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("bear",  CreateColor(225, 0, 0)) ;
DefineGlobalColor("pretrend", CreateColor (200, 125, 255)) ;
# ########################################################

Plot RSI = reference RSI("price" = PRICE, "length" = rsi_length);
# ########################################################
#RSI> RSI[1] this statement is saying if the current candle is greater than the previous candle
#that is what [1] denotes. Thus defining uptick. The same is then done for downticks.
RSI.AssignValueColor(
if RSI> OB then GlobalColor("maxxed") else
if RSI< OS then GlobalColor("pretrend") else
if RSI> RSI[1] then GlobalColor("rising")
else GlobalColor("bear"));
RSI.SetLineWeight(3);
# ########################################################

plot OverBought = OB;
plot OverSold = OS;
plot UpArrow = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownArrow = if RSI crosses below OverBought then OverBought else Double.NaN;

DefineGlobalColor("OBcolor", CreateColor(171, 171, 225)) ;
DefineGlobalColor("OScolor", CreateColor(220, 220, 128)) ;
OverBought.SetDefaultColor(GlobalColor("OBcolor"));
OverSold.SetDefaultColor(GlobalColor("OScolor"));
UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpArrow.SetDefaultColor(color.dark_green);
DownArrow.SetDefaultColor(color.dark_red);
# ########################################################
# The same logic that was used in coloring the plot can be used in labels
if RSI> OB then "RSI maxxed" else
if RSI< OS then "RSI pre-trend" else
if RSI> RSI[1] then "RSI Trending " +round(RSI,2)
else "RSI Bear " +round(RSI,2) ,
if RSI> OB then GlobalColor("maxxed") else
if RSI< OS and RSI>RSI[1] then GlobalColor("pretrend") else
if RSI> RSI[1] then GlobalColor("rising")
else GlobalColor("bear"));
AddCloud(if RSI >= OB then RSI else Double.NaN, OB,
GlobalColor("maxxed"), GlobalColor("maxxed"));
AddCloud(if RSI <= OS then OS else Double.NaN, RSI,
GlobalColor("pretrend"), GlobalColor("pretrend"));
# ########################################################``````

Is it possible to plot colors on indicator-A based upon the data of indicator-B (unplotted) ? So to optimize A without cluttering the monitor up with B ?
Moe specifically, if I wanted the ProjOscillator to be green when RSI>50, and red when RSI <50 ... is that easily done ? I ask because most color plotting I see relates to indicator: & candles, or the indicator itself. Thanks !

Is it possible to

Is it possible to plot colors on indicator-A based upon the data of indicator-B (unplotted) ? So to optimize A without cluttering the monitor up with B ?
Moe specifically, if I wanted the ProjOscillator to be green when RSI>50, and red when RSI <50 ... is that easily done ? I ask because most color plotting I see relates to indicator: & candles, or the indicator itself. Thanks !
Great question! And an interesting idea. I don't know what a ProjOscillator is, so for the point of illustration, I used the Awesome Oscillator.
Just replace it w/ your code.

To give back to the community can you share the script that you create and perhaps a screenshot?
Unsure of how to upload screenshots to the forum, Here are directions.

Ruby:
``````declare lower ;

def  whatever_projoscillator_definition_is = reference AwesomeOscillator() ;
plot projOscillator =  whatever_projoscillator_definition_is ;

projOscillator.AssignValueColor(
if RSI() > 50 then color.green else color.red);``````

Whoa ... cool. I got it to work. Glad I found this site. Thx !

Whoa ... cool. I got it to work. Glad I found this site. Thx !
If it is not proprietary, care to share with the class?

If it is not proprietary, care to share with the class?
You bet. I'm new here so haven't figured it all out, but here's a cut/past of the code;
--------------------------
plot PROSC = if diff != 0 then 100 * (close - MinBound) / diff else 0;
#
# Coding based on MerryDay's input to color PO Green when RSI >50, otherwise Red
#
PROSC.AssignValueColor(if RSI() > 50 then color.green else color.red);
------------------------------------

Here is TOS link to description of Projection Oscillator description;
https://tlc.thinkorswim.com/center/...tors/studies-library/O-Q/ProjectionOscillator
.. and the related Projection Bands
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/O-Q/ProjectionBands

I'm new to the PO, so trying to see if other studies added to it remove some of the noise. Starting with the RSI>50, and will take a look into MA stacks, stochastics, other ... dunno yet

87k+ Posts
382 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?