indicator() - Pine Script Function
indicator()
Section titled “indicator()”Overview
Section titled “Overview”Every indicator script must start with indicator(). This declaration names the script, decides whether plots appear on the price chart, and sets limits (labels, lines, boxes). Many arguments are optional; you only need to supply the ones you rely on.
Syntax
Section titled “Syntax”indicator(title, shorttitle, overlay, format, precision, scale, max_bars_back, timeframe, timeframe_gaps, explicit_plot_zorder, max_lines_count, max_labels_count, max_boxes_count, calc_bars_count, max_polylines_count, dynamic_requests, behind_chart) → voidCommon parameters
Section titled “Common parameters”| Name | Type | Description |
|---|---|---|
title | const string | Full name shown in the chart and indicators list. Required. |
shorttitle | const string | Optional shorter name displayed on chart overlays. |
overlay | const bool | true plots on the price chart, false plots in a separate pane (default false). |
precision / format | const int/const string | Control numerical formatting of plots. |
max_lines_count, max_labels_count, max_boxes_count | const int | Increase drawing limits when you need more objects. |
timeframe, timeframe_gaps | const string/const bool | Run the indicator on a different resolution and control gap handling. |
dynamic_requests | const bool | Allow request.* calls with dynamic symbols/timeframes (Pine v5). |
See the TradingView docs for the full list.
Remarks
Section titled “Remarks”indicator()must appear before any plotting or logic.- Indicators cannot trade—use
strategy()when you need order functions. - Set drawing limits only as high as required; overly large values slow scripts.
Example
Section titled “Example”//@version=5indicator("Adaptive EMA", shorttitle="AEMA", overlay=true, max_lines_count=5)
lenFast = input.int(12, "Fast length")lenSlow = input.int(26, "Slow length")emaFast = ta.ema(close, lenFast)emaSlow = ta.ema(close, lenSlow)
plot(emaFast, "Fast", color=color.teal)plot(emaSlow, "Slow", color=color.orange)plot(close, "Close", color=color.new(color.gray, 70))