Zopra/Charts
Guide
Getting startedAll chartsWhich chart to use?Domain specific
Base charts7
XY ChartTrendCandlestickHeatmapState TimelineFlame GraphBar Gauge
Derived charts73
Time SeriesHistogramStatus HistoryStatGaugeHoneyCombTracesNode GraphHeikin-AshiRenkoKagiPoint & FigureParetoIshikawaControl ChartBland-AltmanLollipopDumbbellSlopeBumpBack-to-BackWaterfallBulletFunnelMekkoForestBarcodeBeeswarmRidgelineHorizonSpectrogramAttention MapWaffleVennUpSetWarped WaffleWord CloudGanttSankeySankey MatrixTreemap ForceChord DiagramCircosArc DiagramAlluvialSankey FunnelDendrogramIcicleSunburstSpiderNightingale RoseParallel CoordinatesOscilloscopeEfficient FrontierPhase PortraitPoincaré MapBifurcationH-R DiagramRamachandranHarkerRoot LocusRadiation PatternQuiverHodographSmith ChartEye DiagramSequence LogoTernaryTernary ContourPiperStüveTephigramChoropleth

Charts/Finance charts

Kagi

<Kagi /> · 10 examples

One connected line that changes direction only when the price reverses by a set amount, thick when demand is winning.

Overview

Most price charts are a diary: here is what happened at 9:30, here is what happened at 9:35. A Kagi chart is closer to a sketch of the argument. It does not care when things happened. It only cares which way the price was going, and whether the last move against it was big enough to count as a change of mind.

It comes from Japanese markets and is usually said to be named after the word for a key, which the zigzags resemble. Western traders met it mostly through Steve Nison's books on Japanese charting. The drawing rule is almost comically simple: draw a vertical line while the price continues in one direction, and when it reverses by at least your chosen amount, step sideways and draw a new line the other way.

The part that earns the chart its keep is the thickness. When the price breaks above an earlier high, the line turns thick (yang). When it breaks below an earlier low, the line turns thin (yin). So a glance at the width tells you whether buyers or sellers have been in charge, which is more than a line chart will ever say, for the price of a slightly odd-looking picture.

Props

API

<Kagi data={bars} close={|b: &Bar| b.close} reversal={3.} />
PropTypeDefault
dataas aboverequired
closeFn(&T) -> f64required
reversalf64: how far the price must turn back to start a new line2% of the mean close, rounded
yang, yincolours of the thick (rising) and thin (falling) linesgood and bad
y_axis, tooltip, class

The line keeps going while the price moves in the same direction and turns when it reverses by reversal. It turns thick (yang) when it rises above the last shoulder and thin (yin) when it falls below the last waist.

Run them

10 examples

Press Run to load an example into the live render at the top of the page. Open one to read its code.

How to read it

  1. 01Follow the line from left to right. Each vertical stretch is a move in one direction, and each sideways step is a reversal.
  2. 02Read the thickness. Thick means the price has just broken above an earlier high, thin means it has broken below an earlier low.
  3. 03Watch for the switch. Thin to thick is the price taking out a previous high, and it is the signal this chart is best known for.
  4. 04Hover to read the levels. The x axis is the number of the line, so it will give you a price and a count, not a date.

When to use it, and when not to

Reach for it when

  • You want the swings of a price that matter, and a single line to follow, with no gaps and no time axis.
  • You are looking for trend changes, where the line switches from thin to thick or the reverse, as a clearer signal than a colour flip.
  • You have closes at any resolution and a reversal size that is meaningful to you: 2%, or a fixed dollar amount.
  • You want a simple, historic way to separate demand-led moves from supply-led ones.

Skip it when

  • You need to know when things happened. The x axis counts lines, not minutes.
  • You need the intraday range. Only closes are used. Highs and lows are ignored.
  • Your reversal amount is arbitrary. A small one makes a hectic zigzag and a large one makes a few lines. Try a couple of values before trusting any one.
  • Your audience has never seen one. The thick and thin lines need a sentence of explanation. Candlestick needs none.

The math behind it

Building the lines

Kagi works on closes p1,p2,…p_1, p_2, \dotsp1​,p2​,… and a reversal amount rrr. It keeps a list of line end-points, starting with the first close. Until the price has moved by at least rrr from that start, nothing is drawn, and the first move that does fixes the first direction d∈{+1,−1}d \in \{+1, -1\}d∈{+1,−1}.

Afterwards, for each new close ppp, let eee be the end of the current line. If ppp is further in the current direction, the line is extended: e←pe \leftarrow pe←p. Otherwise, if ppp is at least rrr against the direction, the direction flips and a new line is started that ends at ppp. Moves against the direction smaller than rrr are ignored.

(p−e) d>0  ⇒  e←p,∣e−p∣≥r  ⇒  d←−d,  new line ending at p(p - e)\,d > 0 \;\Rightarrow\; e \leftarrow p, \qquad |e - p| \ge r \;\Rightarrow\; d \leftarrow -d,\; \text{new line ending at } p(p−e)d>0⇒e←p,∣e−p∣≥r⇒d←−d,new line ending at p

Yang and yin

Each line is labelled thick (yang) or thin (yin) by remembering the last turning points. An up line becomes yang when it ends above the previous up-line's top (the shoulder). A down line becomes yin when it ends below the previous down-line's bottom (the waist). Otherwise the line keeps the thickness it had. The first line is yang if it goes up, yin if it goes down.

Both series are drawn as step lines: the line moves horizontally between lines and vertically along each one. Thick lines are drawn 3.5 px wide and thin ones 1.5 px. A thick segment is also joined to its neighbour so there are no gaps where the thickness changes.

The default reversal

If reversal is not given, the chart uses 2% of the mean close, rounded to two significant figures, so the threshold scales with the price level. The x axis is the line number, an integer count, and the legend lists Yin and Yang.

rdefault=round⁡2 sig(0.02 pˉ)r_{\text{default}} = \operatorname{round}_{2\,\text{sig}}\bigl(0.02\,\bar p\bigr)rdefault​=round2sig​(0.02pˉ​)

Real life usage

The line that changed its mind

Aurelio kept the books for a family-owned olive oil exporter in Andalusia, and for reasons of inheritance, also kept the portfolio. His uncle had left a handful of shares in a shipping company, which the family held in the quiet hope that they would one day be explained to them.

Aurelio did not want to become a trader. He wanted to know, twice a year, whether to sell. A line chart had told him nothing: the price wandered up and down within a few percent for months, and each time he looked at it, it looked like a different story. A candlestick chart looked like a row of tiny arguments.

He wanted a chart that ignored the small stuff and only spoke up when the price truly changed direction, and one that could say whether the buyers or the sellers had the upper hand while it did so.

A friend who worked at a brokerage showed him Kagi. He fed two years of weekly closes into <Kagi> in a small desktop tool built with zopra-charts, set reversal to 3 euros, and was surprised how little there was to look at. The two years became 19 lines.

More surprising was the thickness. For eleven lines the chart was thin. Then it went thick for five, and then, in the seventeenth line, thin again, with the price falling below the earlier low. That thin line was the first signal in two years that anything at all had changed.

He sold two thirds of the holding at 41 euros. The shares closed the year at 33, and the family's one-third remainder is described by his aunt as "the part we are still being reasonable about".

Aurelio now says the chart is mostly useful because of everything it declines to show him. He considers this the same quality he looks for in a good accountant.

Pitfalls

  • Reversal size changes the picture completely. Too small and the chart is as jittery as the price. Too large and a real turn takes two reversals to show.
  • No time axis. Two adjacent lines may be a day or a year apart. Do not read line counts as durations.
  • Thick does not mean up. Thickness shows a break of an earlier high or low. A thick line can be heading down, if it is the stretch before the next shoulder is broken.
  • The first line is a guess. Until the price has moved by one full reversal from the start, nothing is drawn, and the first direction comes only from that first move.
  • Only closes. Intraday spikes and wicks never appear, which is the point, until the one time it is not.

From around the web

Watch and read

YouTubeKagi Charts on TradingView: TutorialTradingViewOfficial tutorial on setting up and reading Kagi charts.
YouTubeKagi Charts Explained: The Complete Technical Analysis GuideWaveLabsExplains the reversal rule and thick/thin line logic behind Kagi charts.

Keep going

Related charts

RenkoWhen you want to drop time too, but draw fixed-size bricks instead of one line.Point & FigureWhen you want to count how far each move went in boxes, as columns of marks.CandlestickWhen the real open, high, low and close of each period are what you need.
PreviousRenkoNextPoint & Figure

On this page

  • Live
  • Overview
  • API
  • Examples
  • How to read it
  • When to use it
  • The math
  • Story
  • Pitfalls
  • Watch and read
  • Related