Home » Ticker Functions » Understanding the ticker.pointfigure() Function in Pine Script

Understanding the ticker.pointfigure() Function in Pine Script

Photo of author
Published on

Introduction to Point and Figure (PnF) Charts in Pine Script

Point and Figure (PnF) charts are a unique way of visualizing price movements in trading. Unlike typical charts, PnF charts do not factor in time. Instead, they focus solely on significant price movements, ignoring minor fluctuations and the passage of time. This is achieved by plotting a series of X’s and O’s – X’s represent a rising price trend, while O’s indicate a falling price trend.

The Role of ticker.pointfigure() in Pine Script

In Pine Script™, the ticker.pointfigure() function plays a crucial role in creating Point and Figure charts. This function generates a ticker ID that can be used with the request.security() function to fetch PnF values. However, it’s important to note that Pine Script™ does not have a built-in function to directly draw these PnF bars on a chart. Instead, the function provides synthetic Open, High, Low, Close (OHLC) PnF values, which can be used for further analysis or visualization.

Example Usage of ticker.pointfigure()

Let’s dive into an example to understand how this function is used in Pine Script:

//@version=5
indicator("", "", true)
// Generate the PnF ticker
pnfTicker = ticker.pointfigure(syminfo.tickerid, "hl", "ATR", 14, 3)
// Fetch the Open and Close values
[pnfO, pnfC] = request.security(pnfTicker, timeframe.period, [open, close], barmerge.gaps_on)
// Plotting the PnF Open and Close values
plot(pnfO, "PnF Open", color.green, 4, plot.style_linebr)
plot(pnfC, "PnF Close", color.red, 4, plot.style_linebr)

Breakdown of the Code

  1. Initialization of the Indicator:
    • indicator("", "", true): This line initializes a blank indicator.
  2. Creating the PnF Ticker:
    • pnfTicker = ticker.pointfigure(...): This function call creates a PnF ticker ID using the current ticker ID (syminfo.tickerid). The parameters “hl”, “ATR”, 14, and 3 define the method of calculation.
  3. Fetching PnF Values:
    • [pnfO, pnfC] = request.security(...): This line uses request.security() to fetch the open (pnfO) and close (pnfC) values of the PnF chart for the current time frame.
  4. Plotting the PnF Values:
    • plot(pnfO, ...): Plots the PnF Open values with green lines.
    • plot(pnfC, ...): Plots the PnF Close values with red lines.

Key Features and Takeaways

  • Functionality: The ticker.pointfigure() function is essential for accessing PnF chart values in Pine Script™.
  • Usage: It works in conjunction with request.security() to retrieve synthetic OHLC values for PnF charts.
  • Application: Useful for traders focusing on price movements rather than time-based analysis.
  • Limitation: Pine Script™ doesn’t provide a direct method to draw PnF bars on the chart.

By understanding and utilizing the ticker.pointfigure() function, traders can incorporate Point and Figure analysis into their trading strategies, offering a different perspective from traditional time-based charts.

Leave a Comment