Resource icon

thinkScript Colors: List of Standard Colors for ThinkorSwim Indicators

You can customize a plot in your thinkScript code by changing its color. Here is a list of available thinkScript colors supported in ThinkorSwim.

The list below is just a set of constants. You can also use other color formats such as RGB in your code.
  • BLACK
  • BLUE
  • CURRENT
  • CYAN
  • DARK_GRAY
  • DARK_GREEN
  • DARK_ORANGE
  • DARK_RED
  • DOWNTICK
  • GRAY
  • GREEN
  • LIGHT_GRAY
  • LIGHT_GREEN
  • LIGHT_ORANGE
  • LIGHT_RED
  • LIME
  • MAGENTA
  • ORANGE
  • PINK
  • PLUM
  • RED
  • UPTICK
  • VIOLET
  • WHITE
  • YELLOW

Usage

Code:
Color.[insert color]

Examples

Ruby:
AddLabel(yes, "Custom Label Text", color.yellow);

The code above sets the color of your AddLabel to yellow.

Here's another example of changing the 20 SMA line. When the closing price is higher than the 20 period moving average, the line is green, else red.

Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2017-2020
#

input price = close;
input length = 20;
input displace = 0;
input showBreakoutSignals = no;

plot SMA = Average(price[-displace], length);
SMA.AssignValueColor(if close > SMA then color.green else color.red);

Additional scripts related to thinkScript Colors

Useful Notes from the thinkScript Lounge

You can use different methods, like global color, or this is one method I use [source]

Code:
plot  trend = 0;
Trend.DefineColor("UpTrend", Color.UPTICK);
Trend.DefineColor("DownTrend", Color.DOWNTICK);
Trend.DefineColor("NeutralUp", Color.LIGHT_GRAY);
Trend.DefineColor("NeutralDn", Color.DARK_GRAY);
Trend.DefineColor(" Default", Color.CYAN);
Trend.Hide();

input PaintBars = yes; #hint PaintBars: Whether or not to paint price bars. Only one script on your chart can paint price candles.
AssignPriceColor(
     if PaintBars then
        if U and D OR NB then  
            if c<o then Trend.Color("NeutralDn")
                else Trend.Color("NeutralUp")  
            else if U then Trend.Color("UpTrend")  
            else if D then Trend.color("DownTrend")
        else  Color.CURRENT
     else Color.CURRENT);

Example of using current value of variable to control color of entire plot [source]

Code:
# Example of using current value of variable to control color of entire plot

def c = close;
def bn = BarNumber();
def na = Double.NaN;
def cb = HighestAll(if !IsNaN(c) then bn else na);
def green = c > open;
def greenLine = HighestAll(if bn == cb then green else na);
def currentClose = HighestAll(if bn == cb then c else na);

plot
priceLine = currentClose;
priceLine.AssignValueColor(if   greenLine
                           then Color.UpTick
                           else color.DownTick);

15:20 Mobius©: 15m... You can add as many colors to the AssignBackgroundColor() expression as you can dream up conditions for want. [source]

Code:
AssignBackgroundColor( if cond1 then color.blue
                  else if cond2 then color.green
                  else if cond3 then color.red
                  else if cond4 then color.yellow
                  else color.white);
Author
BenTen
Views
2,489
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from BenTen

Latest reviews

Informative & easy to understand.
Top