Usage
AddLabel(visibility option, your text, color);
Example
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
#
# 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
- https://usethinkscript.com/threads/...rategy-for-thinkorswim.3722/page-2#post-77231
- https://usethinkscript.com/threads/help-needed-with-conditionals-on-addlabel.1853/
- https://usethinkscript.com/threads/display-rsi-label-on-thinkorswim.798/
- https://usethinkscript.com/threads/addlabel-box-to-display-ma-cross-on-different-tf.1430/
Useful Notes from the thinkScript Lounge
Labels with symbol [source]## 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
############
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);