Referencing plot color in thinkscript

epete

New member
VIP
How do I reference the color of this ArrowDown in ThinkScript? I want to use the same color when plotting something else.

Arrown-Down-Color.png
 
Last edited:

OBW

Member
Thanks, I was actually hoping to get whatever color the user had chosen for the ArrowDown; to use that same color in another place.

Use "global" colors. https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/DefineGlobalColor

Define the global color, then use that color in all the places that you want to be changed when the user picks the color under the "global" tab in chart settings.

Ruby:
DefineGlobalColor("Arrow Down Color", Color.PINK);
def ma5 = Average(close, 5);
def ma13 = Average(close, 13);
plot arrow_down = ma5 crosses below ma13;
arrow_down.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
arrow_down.SetLineWeight(5);
arrow_down.AssignValueColor(GlobalColor("Arrow Down Color"));
AddLabel(yes, "This color will change when the user changes 'Arrow Down Color'", GlobalColor("Arrow Down Color"));
AddChartBubble(high == HighestAll(high), high, high, GlobalColor("Arrow Down Color"));
AddChartBubble(low == LowestAll(low), low, low, GlobalColor("Arrow Down Color"), 0);

OudbxsO.gif
 
Last edited:

rad14733

Well-known member
VIP
@epete I think what you are asking is what color code is being used for different indicators... You can find it by clicking on the colored box and then going to the RGB tab, or one of the others... That gives the numeric representation of a color that you can then replicate in whatever way you desire... This allows you to use a more diverse color pallet than the default 16 colors in the selector grid... Is this more the answer you were looking for...???
 

MerryDay

Well-known member
VIP
To find how that color is defined:

aaa2.png


Code:
#To define a custom color in TOS, plug the RGB codes into the following statement:
DefineGlobalColor("FunkyCoral",  CreateColor(255, 175, 175)) ;
#To use a custom color use (put the name of variable you want colored before the dot)
your_arrow.SetDefaultColor(GlobalColor("FunkyCoral"));
 
Last edited by a moderator:

epete

New member
VIP
What I was looking for is if there is a way in ThinkScript to reference whatever the ArrowDown color is. Kind of like "Color.ArrowDown". So no matter which color the user selects for ArrowDown, my code would reference that and use the same color. What I'm really looking for is the syntax to use to reference the color of the ArrowDown. Thanks
 

Mindflux

New member
Is there a way to match label color to indicator color? I'm using .SetDefaultColor(GetColor(1)) to set the indicator color, that way it's set to a default pallet or whatever is chosen in the picker, but I cannot figure out how to make a label have the same color (as set by the color picker if the user changes it).

Right now I'm using

Code:
AddLabel(emaShort, "EMA " + emaShort, (if AvgExpShort > AvgExpMid then Color.GREEN else Color.CYAN));

But would like to use something like

Code:
AddLabel(emaShort, "EMA " + emaShort, (if AvgExpShort > AvgExpMid then Color.GREEN else object.SetDefaultColor(GetColor(1))));
but it claims that setdefaultcolor returns a void and cannot be used there.
 
does anyone know the actual color numbers of the default colors 0-9? one of the studies i'm using is super neon green but it says the color regular ole
Code:
color.green;
and I want to play around with it a little bit to see if I find something that sticks out more or doesn't hurt the eyes as much.
 

BayTrader_93

New member
Use "global" colors. https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/DefineGlobalColor

Define the global color, then use that color in all the places that you want to be changed when the user picks the color under the "global" tab in chart settings.

Ruby:
DefineGlobalColor("Arrow Down Color", Color.PINK);
def ma5 = Average(close, 5);
def ma13 = Average(close, 13);
plot arrow_down = ma5 crosses below ma13;
arrow_down.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
arrow_down.SetLineWeight(5);
arrow_down.AssignValueColor(GlobalColor("Arrow Down Color"));
AddLabel(yes, "This color will change when the user changes 'Arrow Down Color'", GlobalColor("Arrow Down Color"));
AddChartBubble(high == HighestAll(high), high, high, GlobalColor("Arrow Down Color"));
AddChartBubble(low == LowestAll(low), low, low, GlobalColor("Arrow Down Color"), 0);

OudbxsO.gif
I have two plots but I want to be able to define them so I only have to access the global color and change it once rather than for both plots, how can I do this?
 

BayTrader_93

New member
I have a really simple code which I input specific price points to create a range and I want to assign one global color for the plots so I can change when the stock is in a bullish or bearish trend. How can I input the global color function to add this feature to this code?

#Start
input UpperRange = 130.00;
input LowerRange = 131.00;
input showlabels = yes;

plot l1 = UpperRange;
plot l2 = LowerRange;
#End
 

XeoNoX

Well-known member
VIP
@BayTrader_93

Code:
input UpperRange = 130.00;
input LowerRange = 131.00;
input showlabels = yes;
plot l1 = UpperRange;
plot l2 = LowerRange;
l1.SetDefaultColor(color.magenta);
l2.SetDefaultColor(color.magenta);

tested and worked on AAPL
 

Similar threads

Top