Pine Script v6 GuideDrawing Types: 5Max Limit: 500

TradingView Drawings with Pine Script v6

Learn how to programmatically draw custom trendlines, support and resistance levels, order block boxes, dynamic signal labels, and HUD tables on TradingView charts with Pine Script v6.

The 5 Core Drawing Types in Pine Script v6

Unlike standard plot() statements that draw continuous series from left to right, drawing objects can be instantiated dynamically anywhere on the chart, modified across bars, and extended into future space.

1. line.new() • Trendlines & Levels

Draws a straight line between two points (x1, y1) and (x2, y2). Supports custom colors, line widths, and styles (solid, dashed, dotted). Use extend=extend.right to project ray lines.

2. box.new() • Zones & Order Blocks

Creates rectangular areas defined by left, top, right, and bottom coordinates. Ideal for highlighting Fair Value Gaps (FVG), institutional order blocks, and session ranges.

3. label.new() • Markers & Text Tooltips

Places dynamic text markers on or around candles. Supports custom shapes (arrows, balloons, flags), font sizes, and relative anchors such as yloc.abovebar or yloc.belowbar.

4. table.new() • On-Screen Dashboards

Renders stationary grid HUDs anchored to chart corners (e.g. position.top_right). Ideal for displaying multi-timeframe RSI matrices, profit/loss stats, or account metrics.

5. polyline.new() • Multi-Segment Paths

Connects multiple sequential points into complex geometric shapes, wave patterns (Elliott Wave), or custom polygon fills.

Complete Pine Script v6 Drawings Example

The script below demonstrates creating horizontal levels, drawing dynamic order block boxes on pivot highs, and printing signal labels with multi-line text formatting.

Pine Script v6 • Drawing Objects Template
//@version=6
indicator("Pine Script v6 Drawings Demo [Pineify]", overlay=true, max_boxes_count=500, max_lines_count=500, max_labels_count=500)

// ---------------- 1. Drawing a Horizontal Support/Resistance Line ----------------
var line sr_line = na
if barstate.islast
    // Draw line from 50 bars ago to current bar
    sr_line := line.new(
         x1=bar_index - 50, y1=high[50],
         x2=bar_index,      y2=high[50],
         xloc=xloc.bar_index,
         color=color.blue, width=2, style=line.style_dashed
     )

// ---------------- 2. Drawing a Supply/Demand Zone Box ----------------
var box order_block = na
is_pivot_high = ta.pivothigh(high, 5, 5)
if not na(is_pivot_high)
    order_block := box.new(
         left=bar_index - 5, top=high[5],
         right=bar_index + 10, bottom=low[5],
         border_color=color.red, bgcolor=color.new(color.red, 85)
     )

// ---------------- 3. Drawing an Informational Label ----------------
if ta.crossover(ta.ema(close, 9), ta.ema(close, 21))
    label.new(
         x=bar_index, y=low,
         text="Bullish Cross\nPrice: " + str.tostring(close, "#.##"),
         yloc=yloc.belowbar,
         color=color.green, textcolor=color.white,
         style=label.style_label_up, size=size.small
     )
Important Performance Rule: Always declare max_boxes_count=500 and max_lines_count=500 in your indicator() declaration. Without these parameters, Pine Script defaults to a conservative limit of 50 drawings, causing earlier lines and boxes to be deleted unexpectedly.

Build Complex Drawings Without Coding

Create custom order blocks, liquidity zone boxes, and on-chart dashboard tables using Pineify’s visual drag-and-drop builder.

Frequently Asked Questions