Mentis course
Lesson 9. Drawing: labels, lines, boxes and tables
35 min, intermediate level
Plots are one value per bar. Drawings are objects you create and change: label.new, line.new, box.new, table.new.
//@zscript 1
indicator("Pivots", overlay=true)
ph = ta.pivothigh(high, 5, 5)
if not na(ph)
label.new(bar_index - 5, ph, "H", style=label.style_label_down)
A pivot needs bars on both sides to be confirmed, so it is known five bars late. Placing the label at bar_index - 5 puts it where the pivot really was, and never reads a future bar.
Each kind has a maximum on screen. The oldest are removed when you exceed it, so delete what you no longer need.
Exercises
- Pivot lows. Add green labels at pivot lows.
- Last-bar table. Show ATR and RSI in a table written only on barstate.islast.
Quick quiz
Why is a pivot known late?
You cannot confirm a peak until later bars fall away.
Which is a drawing?
label.new creates a drawing object.
Education only. Not financial advice. Examples are teaching samples, not trading results.
