Home » Drawing On Charts » Understanding shape.triangleup in Pine Script

Understanding shape.triangleup in Pine Script

Photo of author
Published on

Let’s delve into how shape.triangleup can be utilized in Pine Script to improve your trading strategies and chart analysis.

Introduction to plotshape Function

Before we dive into shape.triangleup, it’s essential to understand the plotshape function, which is the foundation for plotting shapes on charts in Pine Script. The plotshape function allows you to place a shape on your chart whenever a specified condition is met. Its versatility lies in its ability to accept various shape styles, including the upward triangle.

Syntax of plotshape

plotshape(series, title, style, location, color, size, offset, text, textcolor)
  • series: The condition under which the shape will be plotted.
  • title: The name of the shape (optional).
  • style: The style of the shape, e.g., shape.triangleup.
  • location: Where on the chart the shape will be plotted.
  • color: The color of the shape.
  • size: The size of the shape.
  • offset: Horizontal shift of the shape from its original position.
  • text: Text label on the shape (optional).
  • textcolor: Color of the text label (optional).

Utilizing shape.triangleup

The shape.triangleup style is specifically used to plot an upward-pointing triangle on the chart. It’s particularly useful for marking bullish signals or any condition where an upward movement is anticipated.


Let’s say you want to plot an upward triangle every time the closing price crosses above the 20-period simple moving average (SMA). First, we’ll calculate the SMA and then use plotshape with shape.triangleup.

indicator("My Triangle Up Indicator", overlay=true)

sma20 = ta.sma(close, 20)
bullishCross = ta.crossover(close, sma20)

plotshape(bullishCross, title="Bullish Signal", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)

Deep Dive into the Code

  • sma20: Calculates the 20-period simple moving average of the closing prices.
  • bullishCross: Determines when the closing price crosses above the SMA, returning true or false.
  • plotshape(...): Plots an upward triangle (shape.triangleup) below the bar (location.belowbar) in green color when a bullish cross occurs.

Key Features and Takeaways

  • Function Usability: The shape.triangleup when used with plotshape, enhances chart visualizations by marking specific conditions with an upward-pointing triangle, making it easier for traders to identify potential bullish signals.
  • Syntax: The plotshape function’s versatility allows for customization of the shape’s style, location, color, and size, offering flexibility in how signals are visualized.
  • Application: This functionality is highly useful in trading strategies for marking entry points, potential reversals, or any condition that signifies an upward trend.

By incorporating shape.triangleup in your Pine Script strategies, you not only enrich your charts visually but also improve the efficiency and effectiveness of your trading decision-making process.

Leave a Comment