The plotcandle
function in Pine Script allows traders and developers to effectively visualize financial data on charts. It provides an intuitive way to draw candlestick plots, which are the backbone of any financial analysis. This function is flexible and adaptable, accepting various arguments to customize the appearance and information of the plotted candles.
The plotcandle Function
The plotcandle
function has a signature as follows:
plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display) → void
Arguments
Required Arguments
The first four arguments are required. They represent the four key values that define a candlestick.
open
: This is a series of data representing the opening prices of the trading intervals.high
: This is a series of data that represent the highest prices reached within the trading intervals.low
: This series of data represents the lowest prices during the trading intervals.close
: This series denotes the closing prices at the end of the trading intervals.
Optional Arguments
title
: This optional string constant assigns a title to the plotcandle.color
: This optional argument defines the color of the candles. It can be set using color constants likecolor=color.red
orcolor=#ff001a
, or expressions based on conditions such ascolor = close >= open ? color.green : color.red
.wickcolor
: This argument sets the color of the wick of the candles.editable
: A boolean argument that, when set to true, allows the plotcandle style to be edited in the Format dialog.show_last
: This input integer defines the number of candles to plot on the chart, counting from the last bar back to the past.bordercolor
: This argument sets the border color of the candles.display
: This argument controls where the plot’s information is displayed. It supports addition and subtraction of display options.
Remarks
- If one value of open, high, low, or close equals NaN, the bar will not draw.
- The maximal value of open, high, low, or close will be set as ‘high’, and the minimal value will be set as ‘low’.
Example and Explanation
Let’s take a look at an example of the plotcandle
function and explain each line of the code.
//@version=5 indicator("plotcandle example", overlay=true) plotcandle(open, high, low, close, title='Title', color = open < close ? color.green : color.red, wickcolor=color.black)

In the first line, we specify the version of Pine Script used in the code. Here, it is version 5.
The second line declares an indicator with the title “plotcandle example” and sets the overlay to true. Setting overlay=true
displays the plot directly on the price chart.
The third line is where the magic happens. We call the plotcandle
function using opening, high, low, and closing prices as the required arguments. The title of the plotcandle is set as ‘Title’. We’re also setting the candle color based on whether the closing price is higher or lower than the opening price — green if it’s higher and red if it’s lower. The wick color is set to black.
Key Takeaways
The plotcandle
function provides a flexible and customizable way to visualize price data in a candlestick format. It’s crucial to grasp how each argument affects the resulting plot and to experiment with different options to make the chart most beneficial for your analysis.
Conclusion
Mastering the plotcandle
function in Pine Script can greatly enhance your ability to analyze and visualize financial data. It’s not only about showing prices but also about highlighting the market’s behavior during each trading interval, allowing you to make more informed decisions. Happy trading and scripting!