The list below is just a set of constants. You can also use other color formats such as RGB in your code.
- COLOR.BLACK
- COLOR.BLUE
- COLOR.CURRENT
- COLOR.CYAN
- COLOR.DARK_GRAY
- COLOR.DARK_GREEN
- COLOR.DARK_ORANGE
- COLOR.DARK_RED
- COLOR.DOWNTICK
- COLOR.GRAY
- COLOR.GREEN
- COLOR.LIGHT_GRAY
- COLOR.LIGHT_GREEN
- COLOR.LIGHT_ORANGE
- COLOR.LIGHT_RED
- COLOR.LIME
- COLOR.MAGENTA
- COLOR.ORANGE
- COLOR.PINK
- COLOR.PLUM
- COLOR.RED
- COLOR.UPTICK
- COLOR.VIOLET
- COLOR.WHITE
- COLOR.YELLOW
Usage
Color.[insert color]
Examples
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.
#
# 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
- https://usethinkscript.com/threads/using-alpha-channel-in-custom-colors.2882/
- https://usethinkscript.com/threads/...rategy-for-thinkorswim.3722/page-2#post-77231
- https://usethinkscript.com/threads/change-color-line-in-thinkscript.1120/
Useful Notes from the thinkScript Lounge
You can use different methods, like global color, or this is one method I use [source]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]
# 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]
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);