Resource icon

thinkScript AddLabel: Adding Custom Labels to your Chart

Here is how you can add a text label to your chart in ThinkorSwim. Keep in mind that custom labels are automatically placed at the top left corner.

Usage

Code:
AddLabel(visibility option, your text, color);

Example

Ruby:
AddLabel(yes, "DO NOT overtrade", color.red);

Here, I'm placing a custom text label to remind myself not to overtrade.

Indicators with declarations such as declare lower; can also use AddLabel

Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2020
#

declare lower;

plot ImpVol = IMP_VOLATILITY();
AddLabel(yes, Concat("IV = ", ImpVol), color.orange);

The code above displays the stock's Implied Volatility line. We included the AddLabel script to show the current value of IV.

Additional scripts related to AddLabel

Useful Notes from the thinkScript Lounge

Labels with symbol [source]

Code:
## TICK Label
AddLabel(1, "$TIKI =" + close(Symbol = "$TIKI"));
def c = close(Symbol = "vix");
## vix difference Label
AddLabel(1, "VIX diff =" + (c - c[1]));
## vix Label
AddLabel(1, "VIX =" + c);

A coder's point worth noting [source]

When coding a watchlist column, an 'AddLabel' can be substituted for a plot statement, but only one of the two can be used. When using a plot statement, TS looks for double-precision values only for input (no text) while the AddLabel approach accepts text and double-value-numbers which are combined using the 'concat' function. Good to remember!

Used in Squeeze WL
Code:
############
AddLabel(yes,if plot_value == 13 then Concat(">=" , Sq_Count) else if plot_value == 0 then concat("", Sq_Count) else concat("=", Sq_Count)) ;

Assignbackgroundcolor (if (Sq_Count == 0) then color.current
else if Sq_Count > 11 then color.Dark_red
else color.dark_red);
  • Like
Reactions: Trader Raider
Author
BenTen
Views
1,961
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from BenTen

Top