plotarrow() - Pine Script Function
plotarrow()
Section titled “plotarrow()”Overview
Section titled “Overview”plotarrow() converts a numeric series into vertical arrows: positive values draw upward arrows, negative values draw downward arrows, and na values produce no arrow. The absolute magnitude controls arrow height, so tall arrows immediately highlight stronger readings.
Declare your script with overlay=true when you want the arrows to appear on the main price pane.
Syntax
Section titled “Syntax”plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display, format, precision, force_overlay) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
series | series int/float | Values to convert into arrows. Positive numbers plot above the bar, negative numbers below. |
title | const string (optional) | Name displayed in the legend and style dialog. |
colorup | series color (optional) | Color for upward arrows. Defaults to chart theme green. |
colordown | series color (optional) | Color for downward arrows. Defaults to chart theme red. |
offset | simple int (optional) | Shift arrows forward/backward by N bars. |
minheight | input int (optional) | Minimum arrow size in pixels (default 5). |
maxheight | input int (optional) | Maximum arrow size in pixels (default 100). |
display | input plot_display (optional) | Choose where to show arrow data (pane, status line, etc.). |
Other arguments (editable, show_last, format, precision, force_overlay) mirror those in plot().
Remarks
Section titled “Remarks”- Arrows use the close price for their anchor by default. Apply an
offsetif you need them to point to earlier bars (e.g.,offset=-1). - Scale the
seriesyourself when you want consistent arrow heights regardless of magnitude, e.g., useseries = longSignal ? 1 : shortSignal ? -1 : 0. - To hide arrows during certain bars, return
nafrom theseriesexpression.
Example
Section titled “Example”//@version=5indicator("plotarrow() signals", overlay=true)
fast = ta.ema(close, 21)slow = ta.ema(close, 55)
longSignal = ta.crossover(fast, slow)shortSignal = ta.crossunder(fast, slow)
arrowSeries = longSignal ? 1 : shortSignal ? -1 : 0
plotarrow(arrowSeries, title="EMA cross signals", colorup=color.new(color.green, 0), colordown=color.new(color.red, 0), minheight=10, maxheight=50)