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.

 
Last edited:

BenTen

Administrative
Staff
VIP
That color is Magenta.

You can do something like this:

Code:
plot condition = ABC;
condition.SetDefaultColor(color.magenta);
 

epete

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

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);

 
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:



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.
 

Similar threads

Top