Bentrix Docs
HomePricingDashboard

Kagi

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.

The 300 hourly candles it is built from52 turns, reversing on 0.000666667

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 R.

  1. Start. The line begins at the first close and takes its direction from the first move of at least R.
  2. Extend. While rising, every higher close extends the line up. While falling, every lower close extends it down.
  3. Turn. When price comes back from the extreme by at least R, 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
Cthe price read on each candle — the close by default
Rthe reversal amount
extremethe highest price the rising line has reached since it last turned (the lowest, for a falling line)
  1. 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

SettingChoicesNew chart
ReversalAuto, Points, Price, ATR, Percent — the same choices as a Renko boxAuto
SourceClose, Open, High, Low, HL2, HLC3, OHLC4, High/LowClose
Thick line2, 2.5, 3 or 4 px2.5 px
Thin line0.5, 1, 1.5 or 2 px1 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:

FieldWhat it is
time, ordinalthe 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, closeits prices, as above
volumethe ticks of the candles it holds
formingtrue 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)

JSJavaScript

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#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}");
}

GOGo

_ = 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++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)
end

RR

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")
}

RRust

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);
}

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed