Builds a ticker id that serves a Kagi chart for a symbol, reversing after a set price move.
ticker.kagi(symbol, reversal) returns an id that request.security turns into a Kagi series. A Kagi line keeps extending while price continues in its direction and starts a new line when price reverses by the reversal amount. Time plays no part.
The second form, ticker.kagi(symbol, param, style), sets the reversal either from an ATR length ("ATR") or as a fixed size ("Traditional").
Syntax
ticker.kagi(symbol: simple string, reversal: simple int/float) -> simple string
ticker.kagi(symbol: series string, reversal: series int/float) -> series string
ticker.kagi(symbol: simple string, param: simple int/float, style: series string) -> simple string
ticker.kagi(symbol: series string, param: series int/float, style: series string) -> series stringArguments
| Name | Type | Default | Description |
|---|---|---|---|
| symbol | simple/ | required | The ticker id to convert, such as syminfo.tickerid. |
| reversal | simple/ | required | How far price must move against the current line before the chart reverses. |
| param | simple/ | required | With a style: the ATR length for "ATR", or the reversal size for "Traditional". |
| style | series string | required | How the reversal is set: "ATR" or "Traditional". |
Returns
simple/series string: A ticker id string. Pass it to request.security as its symbol argument.
Remarks
- A smaller reversal gives more lines and more noise; a larger one gives fewer, slower reversals.
Example
//@version=6
indicator("Kagi close", overlay = true)
kagiId = ticker.kagi(syminfo.tickerid, 14, "ATR")
kagiClose = request.security(kagiId, timeframe.period, close)
plot(close, "Close", color.gray)
plot(kagiClose, "Kagi close", color.orange, style = plot.style_stepline)See also
Runs on Sidechair