Home » Drawing On Charts » Understanding the shape.circle in Pine Script

Understanding the shape.circle in Pine Script

Photo of author
Published on

The plotshape function is a critical tool for this purpose, and understanding its shape parameter, specifically shape.circle, is essential for creating effective visual markers.

The plotshape Function Overview

Before diving into the shape.circle, let’s quickly recap what the plotshape function is. The plotshape function is used to plot shapes on the chart at specified series or conditions. It’s commonly used to highlight specific conditions, such as buy or sell signals, by plotting shapes like circles, triangles, or squares on the chart.


plotshape(series, title, style, location, color, size, text, textcolor, offset, editable, show_last, display, join, editable_show_last, show_last_y)

The shape.circle Style

When using the plotshape function, the style parameter determines the shape of the marker. The shape.circle is one of the options you can specify for this parameter, plotting a circle on the chart at points where the condition or series is true.


indicator("My Circle Indicator", overlay=true)
priceCrossUp = ta.crossover(close, ta.sma(close, 14))
plotshape(priceCrossUp, title="Cross Up", style=shape.circle, location=location.belowbar, color=color.green, size=size.small)

In this example, a green circle is plotted below the bar whenever the closing price crosses above the 14-period simple moving average (SMA).


Walkthrough of the Example Code

  • indicator("My Circle Indicator", overlay=true): This line declares a new indicator titled “My Circle Indicator” that will be overlaid on the main chart.
  • priceCrossUp = crossover(close, sma(close, 14)): This line calculates a condition where the closing price crosses above the 14-period SMA. priceCrossUp is a series that returns true at bars where the crossover occurs.
  • plotshape(priceCrossUp, ...): This function call plots shapes based on the priceCrossUp series. Whenever priceCrossUp is true, a shape is plotted.
  • style=shape.circle: This specifies that the shape to be plotted is a circle.
  • location=location.belowbar: This positions the circle below the corresponding bar.
  • color=color.green: This sets the color of the circle to green.
  • size=size.small: This defines the size of the circle as small.

Key Features and Takeaways

  • Function Usability: The plotshape function, with the shape.circle style, is highly useful for marking specific events on a chart, such as price crossovers, with an easily identifiable marker.
  • Syntax and Application: The syntax allows for customization of the plotted shape in terms of style, location, color, and size, providing flexibility in highlighting chart features.
  • Visual Aid for Traders: Such visual aids can significantly enhance a trader’s ability to quickly identify key trading signals or conditions without having to manually scan price movements.

In conclusion, understanding and effectively utilizing the shape.circle in Pine Script allows traders and developers to create more interactive and informative charts, ultimately aiding in better decision-making processes in trading strategies.

Leave a Comment