Referencing plot color in thinkscript

epete

Member
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:
That color is Magenta.

You can do something like this:

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

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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:
@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...???
 
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:
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
 
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.
 
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?
 
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
 
@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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
536 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top