Plot chats in Pine Script


Posted by: Invos Research
Published on: January 16, 2023
Plot chats in Pine Script

In Pine Script, the plot() function is used to display data on a chart. The plot() function takes one or more arguments, which can be a constant value, a variable, an expression, or the result of a function call.

Here are a few examples of how to use the plot() function in Pine Script:

  • Plot a constant value:
plot(10)
  • Plot the value of a variable:
var myVariable = sma(close, 5)
plot(myVariable)
  • Plot the result of an expression:
plot(2 * 5)
  • Plot the result of a function call:
plot(sma(close, 5))

You can also customize the appearance of the plot by setting various options like color, linewidth, style, etc.

 

plot(sma(close, 5), color=green, linewidth=2, title="My Plot")

In this example, the plot() function is used to display a Simple Moving Average (SMA) of the close price with a period of 5, with a green color and a linewidth of 2. Additionally, the title of the plot is set to "My Plot".

You can also plot multiple data on the same chart by calling plot() function multiple times with different data.

It's worth noting that the plot() function is used to display data on the chart, but it doesn't affect the trading logic of the strategy. If you want to generate buy or sell signals based on the data plotted, you need to use the strategy.entry() function in conjunction with the plot() function.