Home » Ticker Functions » Understanding ticker.standard Function in Pine Script

Understanding ticker.standard Function in Pine Script

Photo of author
Published on

In Pine Script, the ticker.standard function is an invaluable tool, especially when you’re working with non-standard charts such as Heikin Ashi or Renko. It allows developers to retrieve data from a standard chart regardless of the chart type the script is currently running on. This tutorial aims to delve into the details and use-cases of this function.

What is the ticker.standard function?

ticker.standard allows you to create a ticker to request data from a standard chart. This means that it is unaffected by factors such as extended session, dividend adjustments, currency conversion, and non-standard chart calculations like Heikin Ashi or Renko. This is incredibly useful when you want to compare data between standard and non-standard charts.

Syntax

ticker.standard(symbol) → simple string

Arguments

  • symbol (simple string): A ticker ID that will be converted into its standard form. This argument is optional. By default, it uses syminfo.tickerid.

Returns

The function returns a string that represents the ticker of a standard chart in the “prefix:ticker” format. If the symbol argument does not contain both the prefix and ticker information, the function returns the provided argument as is.

Example in Practice

Let’s walk through an example to see the ticker.standard function in action:

//@version=5
indicator("ticker.standard", overlay = true)

// This script should be run on a non-standard chart such as HA, Renko...

// Requests data from the chart type the script is running on.
chartTypeValue = request.security(syminfo.tickerid, "1D", close)

// Request data from the standard chart type, regardless of the chart type the script is running on.
standardChartValue = request.security(ticker.standard(syminfo.tickerid), "1D", close)

// This will not use a standard ticker ID because the `symbol` argument contains only the ticker — not the prefix (exchange).
standardChartValue2 = request.security(ticker.standard(syminfo.ticker), "1D", close)

plot(chartTypeValue)
plot(standardChartValue, color = color.green)
 ticker.standard Function in Pine Script

Code Explanation:

  1. chartTypeValue: This variable retrieves data from the non-standard chart type that the script is running on.
  2. standardChartValue: This variable is the core of our tutorial. It uses the ticker.standard function to get data from a standard chart type irrespective of the chart type the script is currently running on.
  3. standardChartValue2: Here’s a variant where we’re using just the ticker (syminfo.ticker) without the prefix. In this case, the ticker.standard function simply returns the argument as is because there’s no prefix.
  4. The plot functions display both the current chart type value and the standard chart value. The standard chart value is represented in green for differentiation.

Key Takeaway

The ticker.standard function offers a streamlined way to fetch standard chart data when working with different chart types. It’s especially useful for comparisons and ensuring that data interpretation remains consistent irrespective of the chart type in use.

Conclusion

ticker.standard is an essential tool in Pine Script for ensuring accuracy and consistency, especially when switching between standard and non-standard charts. Understanding its use and integrating it into your scripts will allow for a more nuanced data interpretation and comparison across different chart types.

Leave a Comment