Declares the script as an indicator and sets its title, pane placement, display format and drawing limits.
Put indicator() at the top of the script, once. It names the script and decides whether it draws on the main chart or in its own pane. Without overlay = true, the script gets its own pane under the chart.
format and precision control how values are written in the legend and on the price scale. The max_*_count arguments raise the number of lines, labels and boxes the script may keep; each is limited to 500.
Syntax
indicator(title: const string, shorttitle: const string (optional), overlay: const bool (optional), format: const string (optional), precision: const int (optional), scale: const scale_type (optional), max_bars_back: const int (optional), timeframe: const string (optional), timeframe_gaps: const bool (optional), explicit_plot_zorder: const bool (optional), max_lines_count: const int (optional), max_labels_count: const int (optional), max_boxes_count: const int (optional), calc_bars_count: const int (optional), max_polylines_count: const int (optional), dynamic_requests: const bool (optional), behind_chart: const bool (optional)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| title | const string | required | Name of the script, shown in the legend and the indicator list. |
| shorttitle | const string | title | Short name shown in the legend. The title is used when it is left out. |
| overlay | const bool | false | true draws on the main chart; false draws in a separate pane. |
| format | const string | format. | How values are written: format.inherit, format.price, format.volume or format.percent. |
| precision | const int | na | Number of decimals shown, from 0 to 16. |
| scale | const scale_type | scale. | Price scale the pane uses: scale.right, scale.left or scale.none. |
| max_bars_back | const int | 0 | Longest history lookback the script needs. Accepted and ignored; history is not trimmed. |
| timeframe | const string | "" | Timeframe the script computes on. A value other than the chart's gives a warning and the script runs on the chart's timeframe. |
| timeframe_gaps | const bool | true | Whether higher-timeframe values leave gaps. Accepted and ignored. |
| explicit_plot_zorder | const bool | false | Whether plots stack in code order. Accepted and ignored. |
| max_lines_count | const int | 50 | Most line objects kept. A whole number up to 500. |
| max_labels_count | const int | 50 | Most label objects kept. A whole number up to 500. |
| max_boxes_count | const int | 50 | Most box objects kept. A whole number up to 500. |
| calc_bars_count | const int | 0 | Number of history bars the script computes. Accepted and ignored. |
| max_polylines_count | const int | 50 | Most polyline objects kept. Accepted and ignored. |
| dynamic_requests | const bool | false | Allows request.* calls to take series arguments. Accepted and ignored. |
| behind_chart | const bool | true | Whether overlay plots draw behind the chart's candles. Accepted and ignored. |
Returns
Nothing.
Remarks
- A script has exactly one declaration: indicator, strategy or library.
- On Sidechair: title, shorttitle, overlay, format, precision and the three max_*_count limits take effect. A different timeframe argument gives the warning "This script asks for another timeframe; it runs on the chart's." Use
request.securityfor another timeframe's data.
Example
//@version=6
indicator("Volume ratio", shorttitle = "VR", precision = 2)
ratio = volume / ta.sma(volume, 20)
plot(ratio, "Ratio", color = ratio > 1 ? color.green : color.gray, style = plot.style_columns)
hline(1)See also
Runs on Sidechair