thinkScript visual styling
thinkScript Colors
Use Color constants, CreateColor, GetColor, and DefineColor to style plots, labels, and backgrounds in thinkorswim. The full list of 25 standard colors plus copyable code examples for each method.
FastMA.SetDefaultColor(Color.CYAN);
SlowMA.SetDefaultColor(Color.MAGENTA);
AddLabel(yes, "Fast: " + AsText(FastMA),
if FastMA > SlowMA
then Color.GREEN
else Color.RED);- Standard colors
- 25 Color constants
- Custom colors
- CreateColor with RGB values
- Palette colors
- GetColor with index 0 to 9
Direct answer
Four ways to use color in thinkScript
These examples cover four color mechanisms. Color constants cover the 25 standard colors. CreateColor builds a custom color from RGB values. GetColor picks from a 10-color palette. DefineColor names custom colors on a plot for use with AssignValueColor.
Color constants
# Using Color constants
plot FastMA = Average(close, 9);
plot SlowMA = Average(close, 21);
FastMA.SetDefaultColor(Color.CYAN);
SlowMA.SetDefaultColor(Color.MAGENTA);
AddLabel(yes, "Fast: " + AsText(FastMA),
if FastMA > SlowMA then Color.GREEN else Color.RED);Use Color.NAME with SetDefaultColor, AddLabel, or any function that accepts a color.
CreateColor (custom RGB)
# Using CreateColor for custom RGB
plot Price = close;
Price.SetDefaultColor(CreateColor(255, 220, 210));Pass red, green, and blue values from 0 to 255. Useful when no standard constant matches your design.
GetColor (palette)
# Using GetColor from the palette
plot SMA = Average(close, 12);
plot EMA = ExpAverage(close, 12);
SMA.SetDefaultColor(GetColor(1));
EMA.SetDefaultColor(GetColor(5));Returns a color from the 10-color palette. Colors vary by Look and Feel settings; check readability with your chart background.
DefineColor (conditional)
# Using DefineColor for conditional coloring
declare lower;
plot Price = close;
Price.DefineColor("Up", Color.UPTICK);
Price.DefineColor("Down", Color.DOWNTICK);
Price.AssignValueColor(
if Price >= Price[1]
then Price.Color("Up")
else Price.Color("Down"));Define named colors on a plot, then reference them with Price.Color("name") in AssignValueColor.
Full list
All 25 standard Color constants
Each constant is prefixed with Color. in thinkScript. For example, Color.CYAN. Swatches are illustrative web colors, not verified platform RGB values. CURRENT preserves the applicable current color rather than defining a fixed swatch.
Primary sources
Official thinkScript references used here
Frequently asked questions
How do I set a plot color in thinkScript?
Call SetDefaultColor on the plot name and pass a Color constant. For example, MyPlot.SetDefaultColor(Color.CYAN) sets the plot to cyan. You can also use CreateColor for custom RGB values or GetColor for palette colors.
What Color constants are available in thinkScript?
thinkScript provides 25 standard Color constants including CURRENT, BLACK, BLUE, CYAN, GREEN, RED, MAGENTA, YELLOW, WHITE, GRAY, ORANGE, PINK, VIOLET, LIME, PLUM, UPTICK, DOWNTICK, and light and dark variants of several colors.
How do I create a custom color with RGB in thinkScript?
Use CreateColor(red, green, blue) with RGB values from 0 to 255. For example, CreateColor(255, 220, 210) produces a light pink. Pass the result to SetDefaultColor, AddLabel, or any function that accepts a CustomColor.
What does GetColor do in thinkScript?
GetColor(index) returns a color from the predefined palette. The palette has 10 colors that repeat in a cycle. The exact colors depend on the current Look and Feel settings, and out-of-range indices wrap as AbsValue(index) % 10. Check contrast in your chosen chart theme.
How do I change a color based on a condition?
Use AssignValueColor with an if-then-else expression, or pass a conditional expression to the color parameter of AddLabel. For multi-state coloring, use DefineColor to name custom colors on the plot, then reference them with Price.Color("name").
Can Pineify generate thinkScript with the right colors?
Yes. Describe the visual style you want in plain English. The Pineify thinkorswim AI Coding Agent can draft color logic. It does not compile or execute the result in thinkorswim; review the source and inspect colors in your actual chart theme.
Style your thinkScript with the right colors
Describe the visual style you want in plain English. The Pineify thinkorswim AI Coding Agent can draft color logic. Review it in the thinkorswim Editor and test the appearance in your chart theme; generated code can contain mistakes.
This page is for educational and informational purposes. It does not provide investment advice, predict future prices, or guarantee trading results.