Label shapes for label.new: speech-bubble pointers in every direction, plus arrows, circles, flags and plain-text styles.
label.style_* constants go in the style argument of label.new and label.set_style. The label_* styles are text bubbles with a pointer: label.style_label_up points up at the bar, label.style_label_down (the default) points down, and label_left, label_right, label_center, label_upper_left, label_upper_right, label_lower_left and label_lower_right place the pointer at that side or corner.
The shape styles (arrowup, arrowdown, triangleup, triangledown, circle, cross, xcross, diamond, flag, square) draw a marker instead of a bubble, with the text beside it. label.style_none draws only the text on no background, and label.style_text_outline draws text with an outline in the label colour.
Constants
| Name | Value | Description |
|---|---|---|
label.style_arrowdown | A downward arrow marker. | |
label.style_arrowup | An upward arrow marker. | |
label.style_circle | A circle marker. | |
label.style_cross | A plus-shaped cross marker. | |
label.style_diamond | A diamond marker. | |
label.style_flag | A flag marker. | |
label.style_label_center | A text bubble centred on the point, with no pointer. | |
label.style_label_down | A text bubble with its pointer facing down; the default. | |
label.style_label_left | A text bubble with its pointer on the left side. | |
label.style_label_lower_left | A text bubble with its pointer at the lower-left corner. | |
label.style_label_lower_right | A text bubble with its pointer at the lower-right corner. | |
label.style_label_right | A text bubble with its pointer on the right side. | |
label.style_label_up | A text bubble with its pointer facing up. | |
label.style_label_upper_left | A text bubble with its pointer at the upper-left corner. | |
label.style_label_upper_right | A text bubble with its pointer at the upper-right corner. | |
label.style_none | Text only, with no bubble or marker. | |
label.style_square | A square marker. | |
label.style_text_outline | Text with an outline in the label colour, and no bubble. | |
label.style_triangledown | A downward-pointing triangle marker. | |
label.style_triangleup | An upward-pointing triangle marker. | |
label.style_xcross | An x-shaped cross marker. |
Remarks
- The label's color argument is the bubble or marker colour; textcolor is the text. For
label.style_noneandlabel.style_text_outlinethe text takes its colour from textcolor. - A pointer style sits relative to the label's y coordinate:
label.style_label_downputs the bubble above the point,label.style_label_upputs it below.
Example
//@version=6
indicator("Pivot labels", overlay = true)
ph = ta.pivothigh(high, 5, 5)
pl = ta.pivotlow(low, 5, 5)
if not na(ph)
label.new(bar_index - 5, ph, str.tostring(ph, "#.##"), style = label.style_label_down, color = color.red, textcolor = color.white)
if not na(pl)
label.new(bar_index - 5, pl, str.tostring(pl, "#.##"), style = label.style_label_up, color = color.green, textcolor = color.white)See also
Runs on Sidechair