Non-standard charts data
Introduction
These functions allow scripts to fetch information from non-standard bars or chart types, regardless of the type of chart the script is running on. They are: ticker.heikinashi(), ticker.renko(), ticker.linebreak(), ticker.kagi() and ticker.pointfigure(). All of them work in the same manner; they create a special ticker identifier to be used as the first argument in a request.security() function call.
`ticker.heikinashi()`
Heikin-Ashi means average bar in Japanese. The open/high/low/close values of Heikin-Ashi candlesticks are synthetic; they are not actual market prices. They are calculated by averaging combinations of real OHLC values from the current and previous bar. The calculations used make Heikin-Ashi bars less noisy than normal candlesticks. They can be useful to make visual assessments, but are unsuited to backtesting or automated trading, as orders execute on market prices — not Heikin-Ashi prices.
The ticker.heikinashi() function creates a special ticker identifier for requesting Heikin-Ashi data with the request.security() function.
This script requests the close value of Heikin-Ashi bars and plots them on top of the normal candlesticks:
Note that:
- The close values for Heikin-Ashi bars plotted as the black line are very different from those of real candles using market prices. They act more like a moving average.
- The black line appears over the chart bars because we have selected “Visual Order/Bring to Front” from the script’s “More” menu.
If you wanted to omit values for extended hours in the last example, an intermediary ticker without extended session information would need to be created first:
Note that:
- We use the ticker.new() function first, to create a ticker without extended session information.
- We use that ticker instead of syminfo.tickerid in our ticker.heikinashi() call.
- In our
request.security()
call, we set the
gaps
parameter’s value tobarmerge.gaps_on
. This instructs the function not to use previous values to fill slots where data is absent. This makes it possible for it to return na values outside of regular sessions. - To be able to see this on the chart, we also need to use a special
plot.style_linebr
style, which breaks the plots on na values.
This script plots Heikin-Ashi candles under the chart:
Note that:
- We use a tuple with request.security() to fetch four values with the same call.
- We use plotcandle() to plot our candles. See the Bar plotting page for more information.
`ticker.renko()`
Renko bars only plot price movements, without taking time or volume into consideration. They look like bricks stacked in adjacent columns1. A new brick is only drawn after the price passes the top or bottom by a predetermined amount. The ticker.renko() function creates a ticker id which can be used with request.security() to fetch Renko values, but there is no Pine Script™ function to draw Renko bars on the chart:
`ticker.linebreak()`
The Line Break chart type displays a series of vertical boxes that are based on price changes1. The ticker.linebreak() function creates a ticker id which can be used with request.security() to fetch “Line Break” values, but there is no Pine Script™ function to draw such bars on the chart:
`ticker.kagi()`
Kagi charts are made of a continuous line that changes directions. The direction changes when the price changes1 beyond a predetermined amount. The ticker.kagi() function creates a ticker id which can be used with request.security() to fetch “Kagi” values, but there is no Pine Script™ function to draw such bars on the chart:
`ticker.pointfigure()`
Point and Figure (PnF) charts only plot price movements1, without taking time into consideration. A column of X’s is plotted as the price rises, and O’s are plotted when price drops. The ticker.pointfigure() function creates a ticker id which can be used with request.security() to fetch “PnF” values, but there is no Pine Script™ function to draw such bars on the chart. Every column of X’s or O’s is represented with four numbers. You may think of them as synthetic OHLC PnF values: