One continuous line that runs with price and turns only when price reverses by a set amount. It turns thick when it rises above an earlier peak and thin when it falls below an earlier trough — a chart of who is in control.
01What you see
A single line that goes up, turns with a short horizontal step (a "shoulder"), comes down, turns again. Its thickness changes as it runs: thick (yang) and thin (yin). Like Renko, time is not on the chart; each turn is one step to the right.
02How it is built
Kagi reads one price per candle — the close by default — and a reversal amount .
- Start. The line begins at the first close and takes its direction from the first move of at least .
- Extend. While rising, every higher close extends the line up. While falling, every lower close extends it down.
- Turn. When price comes back from the extreme by at least , the line turns: a short horizontal shoulder at the extreme, then a new vertical line in the other direction.
rising and extreme − C ≥ R ⇒ turn down
- Thick and thin. The line becomes thick where a rising line passes above the previous shoulder high, and thin where a falling line passes below the previous shoulder low. The change happens exactly at that level, in the middle of a line.
03Reading it
- Thick to thin — price fell below the last trough: sellers have taken over. Many traders read it as a sell.
- Thin to thick — price rose above the last peak: buyers have taken over.
- Tall lines are strong moves; many short turns mean the reversal amount is small for this market, or there is no trend.
- The rising shoulders are higher highs, the falling ones lower lows — the chart is a clean picture of the swing structure.
04Settings
| Setting | Choices | New chart |
|---|---|---|
| Reversal | Auto, Points, Price, ATR, Percent — the same choices as a Renko box | Auto |
| Source | Close, Open, High, Low, HL2, HLC3, OHLC4, High/Low | Close |
| Thick line | 2, 2.5, 3 or 4 px | 2.5 px |
| Thin line | 0.5, 1, 1.5 or 2 px | 1 px |
The picture above uses a reversal of a third of Auto, so the sample's 300 candles make more than a few turns.
05Indicators on Kagi
Computed on the Kagi lines by default — each read as a bar — or on the candles behind them by the study's Calculate on setting. The turn that is forming but has not yet reached the reversal amount is drawn faint.
06From an agent or a program
Set it
chart_set_type turns a chart into this type, as the Chart type card does; style is laid over the chart’s own, field by field — these are its fields and a new chart’s values:
{
"name": "chart_set_type",
"arguments": {
"chart": "<chart uri>",
"type": "kagi",
"style": {
"elements": {
"kagi_reversal": {
"kind": "auto"
},
"kagi_source": "closes"
}
}
}
}Read it
chart_elements_get answers what the chart drew, newest last (at most 5,000; 500 when limit is not given), up to the clock. Each element is read as a bar — here, a segment of the Kagi line, from open to close; the line thickens or thins where it passes a shoulder or a waist:
| Field | What it is |
|---|---|
time, ordinal | the element’s address: the open time (UTC milliseconds) of the time candle whose prices completed it, and its place among the elements that one candle made — a fast hour can make several |
open, high, low, close | its prices, as above |
volume | the ticks of the candles it holds |
forming | true for the last element while it is still being built; it may change or vanish |
An indicator on this chart is computed on these elements by default — study_attach with "on": "candles" computes it on the time candles behind them instead.
In a program
The same two steps in each language — chart, bench and market as in the read the candles guide:
Python
client.chart.set_type(chart, type_="kagi")
drawn = client.data.chart_elements_get(chart, limit=20)
for e in drawn["elements"]:
print("element:", e)JavaScript
await client.chart.setType({ chart, type: "kagi" });
const drawn = await client.data.chartElementsGet({ chart, limit: 20 });
for (const e of drawn.elements) {
console.log("element:", e);
}C#
await client.Chart.SetType(chart, type: "kagi");
var drawn = await client.Data.ChartElementsGet(chart, limit: 20);
foreach (var e in drawn!["elements"]!.AsArray())
{
Console.WriteLine($"element: {e}");
}Go
_ = must(client.Chart.SetType(ctx, mcp.ChartSetTypeArgs{Chart: chart, Type: mcp.Ptr[string]("kagi")}))
drawn := must(client.Data.ChartElementsGet(ctx, mcp.DataChartElementsGetArgs{Chart: chart, Limit: mcp.Ptr[int64](20)}))
for _, e := range at(drawn, "elements").([]any) {
fmt.Println("element:", e)
}Java
client.chart.setType(new Bentrix.ChartApi.SetTypeArgs(chart).type("kagi"));
Object drawn = client.data.chartElementsGet(new Bentrix.DataApi.ChartElementsGetArgs(chart).limit(20L));
for (Object e : (List<Object>) at(drawn, "elements")) {
System.out.println("element:" + " " + e);
}C++
client.chart.set_type(ChartApi::SetTypeArgs(chart).type("kagi"));
auto drawn = client.data.chart_elements_get(DataApi::ChartElementsGetArgs(chart).limit(20));
for (const Json &e : drawn["elements"].arr()) {
std::cout << "element:" << " " << e.dump() << std::endl;
}Julia
client.chart.set_type(chart; type_ = "kagi")
drawn = client.data.chart_elements_get(chart; limit = 20)
for e in drawn["elements"]
println("element:", " ", e)
endR
client$chart$set_type(chart, type = "kagi")
drawn <- client$data$chart_elements_get(chart, limit = 20)
for (e in drawn$elements) {
cat("element:", format(e), "\n")
}Rust
client.chart().set_type(mcp::ChartSetTypeArgs::new(chart.clone()).type_("kagi"))?;
let drawn = client.data().chart_elements_get(mcp::DataChartElementsGetArgs::new(chart.clone()).limit(20))?;
for e in drawn["elements"].as_array().into_iter().flatten() {
println!("element: {}", e);
}