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

Understanding the shape.cross in Pine Script

Photo of author
Published on

The shape.cross function is a constant string used within the plotshape series function to display cross shapes on a chart. This article will dive into how to use shape.cross in Pine Script, providing examples and detailed explanations of the code.

Introduction to shape.cross

The shape.cross function is part of Pine Script’s plotting capabilities, allowing users to mark significant points on a trading chart with cross symbols. This can be particularly useful for signaling the occurrence of certain events, like crossovers of moving averages or specific price actions.

Syntax and Application

To use shape.cross, you’ll typically incorporate it within the plotshape function. The syntax for plotshape that uses shape.cross is as follows:

plotshape(series, style=shape.cross, location=location.belowbar, color=color.red, size=size.small)

Let’s break down this syntax into its components:

  • series: The condition or series when the shape should be plotted. This could be a boolean series where true values represent where crosses should appear.
  • style: This is where you specify the shape.cross to denote the use of cross symbols.
  • location: Determines where the shape will be plotted relative to the price bars. Common locations include location.abovebar, location.belowbar, and location.absolute.
  • color: Sets the color of the cross shape. You can use predefined colors like color.red, or customize it using the color.new() function.
  • size: Dictates the size of the plotted shape. Options include size.auto, size.tiny, size.small, size.normal, size.large, and size.huge.

Example: Plotting Cross Shapes on MA Crossovers

Here’s a practical example where shape.cross is used to highlight crossovers between two moving averages:

indicator("MA Crossover Cross", overlay=true)

// Define moving averages
fastMA = ta.sma(close, 9)
slowMA = ta.sma(close, 21)

// Crossover condition
crossoverCondition = ta.crossover(fastMA, slowMA)

// Plotting crosses on crossovers
plotshape(crossoverCondition, style=shape.cross, location=location.abovebar, color=color.green, size=size.small)

// Displaying moving averages for reference
plot(fastMA, color=color.blue)
plot(slowMA, color=color.orange)

Detailed Walkthrough

  • Moving Averages: Two simple moving averages (SMAs) are defined using ta.sma. fastMA has a period of 9, and slowMA has a period of 21.
  • Crossover Condition: The condition crossoverCondition uses ta.crossover to detect when fastMA crosses above slowMA.
  • Plotting Crosses: plotshape plots cross symbols (shape.cross) above the price bar (location.abovebar) in green color where the crossover condition is met.
  • Displaying MAs: The last two lines plot the moving averages on the chart for visual reference.

Key Features

  • Function Usability: The shape.cross function enriches visual analysis by enabling the precise marking of specific chart points, enhancing the interpretability of trading strategies and signals.
  • Syntax Flexibility: Pine Script’s plotshape function offers flexibility in customizing the appearance and placement of cross shapes, catering to diverse visual analysis needs.
  • Application: Commonly used to signify important events like indicator crossovers, threshold breaches, or signal confirmations, making it a valuable tool for traders and analysts.


  • The shape.cross function in Pine Script is a powerful way to mark significant events on charts, offering clarity and insight into trading strategies.
  • Its integration within the plotshape function allows for flexible customization, ensuring that the visual cues match the user’s analytical needs.
  • By understanding and utilizing shape.cross, traders can enhance their chart analyses, making it easier to identify and react to potential trading opportunities.

Leave a Comment