Introduction to Non-Standard Chart Types in Pine Script
Pine Script, the programming language used on the TradingView platform, offers a powerful feature for traders and analysts: the ability to access data from non-standard chart types. These chart types include Heikin Ashi, Renko, Line Break, Kagi, and Point & Figure. In Pine Script, this is achieved through specific functions, namely ticker.heikinashi()
, ticker.renko()
, ticker.linebreak()
, ticker.kagi()
, and ticker.pointfigure()
. These functions are pivotal for scripts that require data from these specialized chart types, independent of the chart on which the script is running.
Understanding the Functions
ticker.heikinashi()
ticker.renko()
ticker.linebreak()
ticker.kagi()
ticker.pointfigure()
All these functions are designed to create a unique ticker identifier. This identifier is then used as the first argument in the request.security()
function call, which is essential in fetching the required data from these non-standard chart types. It’s important to note that these functions are available in Pine Script version 5, ensuring the latest features and compatibility.
Utilizing Non-Standard Chart Types in Pine Script
1. Heikin Ashi Charts with ticker.heikinashi()
Code Example:
heikinTicker = ticker.heikinashi(syminfo.tickerid) heikinData = request.security(heikinTicker, timeframe.period, close)
Explanation:
- Creating Heikin Ashi Ticker Identifier:
heikinTicker = ticker.heikinashi(syminfo.tickerid)
- This line generates a special ticker identifier for Heikin Ashi charts for the current symbol (
syminfo.tickerid
).
- This line generates a special ticker identifier for Heikin Ashi charts for the current symbol (
ticker.heikinashi()
is the function that converts the standard ticker into a Heikin Ashi ticker.
- Fetching Heikin Ashi Data:
heikinData = request.security(heikinTicker, timeframe.period, close)
- Here,
request.security()
is used to request data from the Heikin Ashi chart. heikinTicker
specifies the Heikin Ashi chart,timeframe.period
denotes the current chart’s timeframe, andclose
indicates that we’re fetching the closing price from the Heikin Ashi chart.
- Here,
2. Renko Charts with ticker.renko()
Code Example:
renkoTicker = ticker.renko(syminfo.tickerid) renkoData = request.security(renkoTicker, timeframe.period, close)
Explanation:
- Creating Renko Ticker Identifier:
renkoTicker = ticker.renko(syminfo.tickerid)
- This line creates a ticker identifier for Renko charts, specific to the current trading symbol.
- Fetching Renko Data:
renkoData = request.security(renkoTicker, timeframe.period, close)
- Retrieves data from the Renko chart using the created ticker identifier. It specifically fetches the closing price for the same timeframe as the current chart.
3. Line Break Charts with ticker.linebreak()
Code Example:
linebreakTicker = ticker.linebreak(syminfo.tickerid) linebreakData = request.security(linebreakTicker, timeframe.period, close)
Explanation:
- Creating Line Break Ticker Identifier:
linebreakTicker = ticker.linebreak(syminfo.tickerid)
- Generates a ticker identifier for Line Break charts.
- Fetching Line Break Data:
linebreakData = request.security(linebreakTicker, timeframe.period, close)
- This line of code requests the closing price data from the Line Break chart, matching the current chart’s timeframe.
4. Kagi Charts with ticker.kagi()
Code Example:
kagiTicker = ticker.kagi(syminfo.tickerid) kagiData = request.security(kagiTicker, timeframe.period, close)
Explanation:
- Creating Kagi Ticker Identifier:
kagiTicker = ticker.kagi(syminfo.tickerid)
- This creates a ticker identifier for Kagi charts.
- Fetching Kagi Data:
kagiData = request.security(kagiTicker, timeframe.period, close)
- Requests closing price data from the Kagi chart, ensuring it matches the timeframe of the current chart.
5. Point & Figure Charts with ticker.pointfigure()
Code Example:
pointfigureTicker = ticker.pointfigure(syminfo.tickerid) pointfigureData = request.security(pointfigureTicker, timeframe.period, close)
Explanation:
- Creating Point & Figure Ticker Identifier:
pointfigureTicker = ticker.pointfigure(syminfo.tickerid)
- Generates a ticker identifier for Point & Figure charts.
- Fetching Point & Figure Data:
pointfigureData = request.security(pointfigureTicker, timeframe.period, close)
- This line fetches the closing price data from the Point & Figure chart for the same timeframe as the current chart.
Key Features and Takeaways
- Function Useability and Syntax:
- Each function creates a special ticker identifier, crucial for accessing data from different chart types.
- The
request.security()
function is used with these identifiers to fetch the required data.
- Application in Trading Strategies:
- These functions are vital for strategies that rely on non-standard chart types for analysis and decision-making.
- They provide a seamless way to integrate different chart types into a single trading strategy.
- Version Compatibility:
- These features are available in Pine Script version 5, ensuring up-to-date functionality and compatibility.
By understanding and utilizing these functions, Pine Script programmers can significantly enhance their trading strategies, incorporating a variety of chart types to gain diverse market perspectives. This guide provides a foundation for exploring these advanced charting options in Pine Script.