AddLabel

AddLabel ( boolean visible , Any text , CustomColor color , int location , int size );

Default values:

color: Color.RED location: Location.TOP_LEFT size: FontSize.SMALL

Description

Adds a text label to the specified location on the chart. Note that you can also use this function to display some text in custom quotes (see example below).

Input parameters

Parameter Default value Description
visible - Defines the condition upon which the label is displayed.
text - Defines the text to be displayed in the label.
color Color.RED Defines the color of the label. You can use a Color constant for this parameter.
location Location.TOP_LEFT Defines the location of the label. You can use a Location constant for this parameter.
size FontSize.SMALL Defines the font size of the label. You can use a FontSize constant for this parameter.

Example

AddLabel(yes, if close > Average(close, 20) then "Uptrend" else "Downtrend", location = Location.TOP_RIGHT, size = FontSize.X_LARGE);

Displays a label in the top-right corner of the chart using the extra large font size. The label shows "Uptrend" if the close price is greater than its 20-bar average, and "Downtrend" otherwise. If used in Custom Quotes, the words "Uptrend" or "Downtrend" will appear in the quote cell based on the same condition.