Home » Plot Functions » Plot arrow Function in Pine Script

Plot arrow Function in Pine Script

Photo of author
Published on

One unique function available in Pine Script is plotarrow(), which enables traders to represent data graphically by drawing up and down arrows on their charts. This function is an excellent tool for visually interpreting positive and negative changes in market data.

What is the plotarrow Function?

The plotarrow() function draws an up arrow for every positive value and a down arrow for every negative value. If the indicator returns na, no arrow is drawn. This is primarily used to denote positive or negative shifts in a dataset or indicator. The height of the arrows varies according to the absolute value of the indicator—the larger the absolute value, the longer the arrow.

Understanding the Syntax of plotarrow

The syntax for the plotarrow() function is as follows:

plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display) → void

Each parameter in this function serves a unique purpose. Let’s go through each one of them:


  • series: Required. It is the series of data to be plotted as arrows.
  • title: The title of the plot.
  • colorup: Optional. This sets the color of the up arrows.
  • colordown: Optional. This sets the color of the down arrows.
  • offset: Optional. This shifts the arrows to the left or right on the given number of bars. The default is 0.
  • minheight: Optional. This sets the minimal possible arrow height in pixels. The default is 5.
  • maxheight: Optional. This sets the maximum possible arrow height in pixels. The default is 100.
  • editable: Optional. If true, then the plotarrow style will be editable in the Format dialog. The default is true.
  • show_last: Optional. If set, it defines the number of arrows to plot on the chart, counting from the last bar backward.
  • display: Optional. This controls where the plot’s information is displayed. The default is display.all.

Working Example of plotarrow in Pine Script

Now that we understand the syntax of plotarrow(), let’s look at a working example that will demonstrate its use:

indicator("plotarrow example", overlay=true)
codiff = close - open
plotarrow(codiff, colorup=color.new(color.teal,40), colordown=color.new(color.orange, 40))

In this script:

  • We first define the version of Pine Script we’re using (//@version=5).
  • Then we use the indicator() function to set the title of the plot and indicate that it will be displayed on the main chart (overlay=true).
  • We calculate the difference between the closing and opening price and assign it to codiff.
  • Finally, we use the plotarrow() function to plot the codiff values as arrows on our chart. For positive values, we use teal arrows, and for negative values, we use orange arrows.

Key Takeaway

The plotarrow() function is a versatile tool in Pine Script that allows traders to visually interpret changes in market data. Understanding how to use it properly can significantly improve the effectiveness and readability of your custom scripts, thus enhancing your trading strategy.


The plotarrow() function in Pine Script brings a unique visual element to trading charts. By displaying data as arrows, it makes trends and changes more apparent and easier to understand at a glance. Whether you are a seasoned trader or just getting started with Pine Script, learning to use this function effectively can provide you with valuable insights that could help improve your trading strategy.

Leave a Comment