VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / How AlphaPrime Computes

Kagi chart backtests: reversal amount, yang and yin, and the late signal

A Kagi chart draws one vertical line that continues while price moves in its direction and turns only after a reversal of a set amount, switching between thick yang and thin yin when it passes the previous shoulder or waist. Kagi backtests overstate results by filling at the turning price and at the shoulder level. AlphaPrime confirms each Kagi line at the close of the underlying bar, fills at the next real price with doubled slippage, and judges stops on the real high and low.

By · Published · updated · Editorial policy

Contents
  1. What is a Kagi chart, and why do Kagi backtests look better than they trade?
  2. How is a Kagi line built from real bars, and when is a turn known?
  3. Where does a Kagi backtest see the future?
  4. Filling at the turn
  5. Filling at the shoulder or waist
  6. Stops on a chart without highs and lows
  7. How does AlphaPrime backtest a Kagi strategy?
  8. How do you choose a Kagi reversal amount for backtesting?
  9. Which markets and strategies suit Kagi charts?
  10. Frequently asked questions

What is a Kagi chart, and why do Kagi backtests look better than they trade?

A Kagi chart is a single line that moves up or down with price and turns only after price reverses by a set amount, changing thickness when it breaks the previous high or low. Kagi backtests look better than they trade because they fill at the turn and at the breakout level, prices that were known only after the fact.

Kagi comes from the Japanese rice markets. A reversal amount is the distance, fixed or as a percentage, that price must move against the current line before the chart turns. A shoulder is the high where a rising line turned down; a waist is the low where a falling line turned up. The line is drawn thick, called yang, after it rises above the previous shoulder, and thin, called yin, after it falls below the previous waist. Traditional Kagi rules buy when the line turns yang and sell when it turns yin. Time is not on the chart; a line can last an hour or a month.

The chart is quiet by design, and that is what traders like about it. The way engines backtest it leans on the same two shortcuts as every other synthetic chart: the turn is treated as known at the extreme, and the fill is taken at a drawn level. The rules shared across all chart types are on the overview of why synthetic-bar backtests cheat; this page is the Kagi-specific part.

How is a Kagi line built from real bars, and when is a turn known?

A Kagi line extends when a completed underlying bar's close moves beyond the line's current end in its direction, and it turns when a completed bar's close has moved the reversal amount against it. The turn is known at that bar's close, not at the extreme the line is drawn from.

This is the heart of the Kagi timing problem. The chart draws the turn at the shoulder, the highest point the rising line reached. Then it draws the new falling line from that shoulder down to the current price. Looking at the finished chart, the turn appears to have happened at the shoulder. In real time, nobody knew the shoulder was a shoulder until price had already fallen the full reversal amount below it. The information arrived at the bottom of the new line, and the chart drew it at the top.

AlphaPrime (Valynox) builds Kagi lines from the closes of the underlying bars you choose, and hands the strategy a bar at each moment the chart changes in a way that cannot be undrawn: when a reversal is confirmed (the close that moved the full reversal amount away from the old line's extreme), when the line changes thickness by crossing the previous shoulder or waist, and each time the line extends by another reversal amount. Each of those bars is visible at the close of the underlying bar that produced it: an extension bar closes at the step level it reached, a thickness-change bar at the close that crossed the level, and a confirmed reversal delivers the old line's last stretch up to its extreme together with the first bar of the new line, which closes at the confirming close. A large gap can produce several extension bars from one underlying bar, and every signal from them fills at the same next real price. Nothing the strategy has seen is ever redrawn, and nothing it has not yet seen is used. A turn is therefore known at the bottom of the new line, not at the shoulder; the chart draws the turn at the shoulder, but nobody knew it was a shoulder until the reversal amount had been covered.

Hypothetical example

Reversal amount 4 points, daily underlying bars. A rising line reaches 130 on Tuesday. Wednesday closes at 128, Thursday at 125. The chart draws a turn at 130 and a falling line to 125. A backtest that sells at the turn is short from 130. AlphaPrime confirms the reversal at Thursday's close (the first close at least 4 points below 130), hands the strategy that event as a bar, and fills a sell at Friday's open plus slippage, around 125. The 5-point difference is the price of knowing a shoulder is a shoulder.

Where does a Kagi backtest see the future?

At the turn, at the shoulder or waist breakout, and in the stop check on a chart that records only closes.

Filling at the turn

Rule: a turn exists only at the close of the bar that completed the reversal amount. Why: the extreme is identified by what happened after it, so acting at the extreme means acting on later data. What it avoids: entries and exits at the best price the chart can express, awarded on every reversal.

Filling at the shoulder or waist

Rule: the yang or yin change is known at the close of the underlying bar whose close crossed the previous shoulder or waist, and the fill is the next real price after that. Why: the crossing bar's close is typically some distance past the level, and the next trade is further still. What it avoids: breakout fills at a level on the chart rather than at a price in the market. With percentage reversal amounts there is a second leak: engines sometimes compute the percentage from a later price than the one available at the time. AlphaPrime computes it from the price at the time, so the threshold never knows what came after.

Stops on a chart without highs and lows

Rule: stops and targets are judged on the underlying bar's high and low, stop first. Why: a close-built Kagi chart never saw the intrabar extremes, so a stop judged on the Kagi line is judged on closes only. What it avoids: a backtest in which stops are hit only on closes, when the account is stopped on ticks.

Kagi eventDrawn-line backtestAlphaPrime
TurnTrade at the shoulder or waist priceKnown at the close that completed the reversal; fill at the next real price
Yang/yin changeFill at the previous shoulder or waist levelKnown at the close that crossed the level; fill at the next real price plus doubled slippage
Reversal amount in percentSometimes computed from a later priceComputed from the price at the time, rounded up to a whole tick
Stop checkCloses onlyReal highs and lows of the underlying bars, stop first
The chart draws the turn at the shoulder; the information arrived several bars later, at the close that completed the reversal amount.
The chart draws the turn at the shoulder; the information arrived several bars later, at the close that completed the reversal amount. AlphaPrime generation settings · chart type panel

How does AlphaPrime backtest a Kagi strategy?

The strategy reads the Kagi line, its thickness and its shoulders and waists. Fills, stops and targets are settled on the underlying bars. Rule by rule:

  • The strategy gets a bar at each change that cannot be undrawn: a confirmed reversal, a thickness change, each further extension by one reversal amount. Why: those are the only moments a close-built chart learns something final, and the forming bar's close is not known. Avoids: turns that are drawn and then erased, and signals that would have had to be recomputed.
  • Market orders are filled at the next underlying bar's open plus slippage. Why: the first available price after the signal exists. Avoids: fills at shoulders, waists and turning points.
  • Percentage reversal amounts are computed from the price at the time, not from a later one, and rounded up to a whole tick. Why: a threshold taken from a later price adapts to what happened next, and rounding down would confirm turns a fraction early. Avoids: a reversal amount that knows the future or is more generous than the chart's own rule.
  • Stops and targets are checked against the underlying bars' real highs and lows, and the stop is taken first. Why: the real bars hold the prices the Kagi line discards. Avoids: stop-outs that the chart cannot see.
  • Slippage carries a multiplier of two that you can raise but not lower. Why: a Kagi turn is confirmed only after price has covered the full reversal amount, which is when the market is moving against the old line fastest. The larger cost, the distance from the line's end to the real fill, is charged by the real-price fill on top of that. Avoids: pricing a confirmed reversal at a quiet-market spread.

A Kagi strategy tested this way shows fewer trades and later entries than its chart version. That is not the engine being unkind. It is the delay that was always built into the chart and that the drawing hides. How to weigh the line-to-fill distance and the doubled slippage against the average trade is covered on the page about commission, slippage and the average trade.

How do you choose a Kagi reversal amount for backtesting?

Choose a reversal amount that is several times your slippage assumption and at least the typical range of the underlying bar; smaller amounts turn the chart into a noisy close-to-close line with Kagi's delay and none of its filtering.

  1. Fixed amount for a single instrument over a few years. On an index future, a daily reversal amount in the range of one to two average daily ranges is a sensible starting point. Test one step larger and one step smaller.
  2. Percentage amount for long histories or for crypto. The percentage applies to the current price, so the threshold grows with price without you touching it; keep the percentage fixed across in-sample and out-of-sample periods.
  3. Average-true-range based amount, computed from completed bars only and frozen for the life of each line. It adapts to volatility without peeking.

Kagi's close cousins make similar choices under different names. Line Break charts reverse on a count of prior lines rather than a price amount, and point and figure charts reverse on a count of boxes. All three share the shoulder-and-turn timing leak described here.

Which markets and strategies suit Kagi charts?

Kagi suits slow trend rules on daily and hourly bars in markets that trend for weeks: index futures, bonds, major currency pairs, metals and the larger cryptocurrencies. It is a poor fit for intraday work, where the reversal amount is either too small to filter anything or too large to produce trades, and for choppy markets, where the yang-yin changes come in pairs and each pair costs two fills.

Before trusting a Kagi result, check two things. First, how many bars pass between a shoulder and the close that confirmed it, on average. That number is your real entry delay, and the chart hides it. Second, whether the strategy still works with the reversal amount one step larger. If the signal count collapses, the rule was trading noise at the edge of the filter. If it holds, run walk-forward analysis on it like any other strategy.

What this means if you use AlphaPrime: choose Kagi as the chart type in strategy generation, set the reversal amount and the underlying resolution, and run the search. Every candidate is tested with turns and thickness changes that count only once their close has printed, fills at the next real price with doubled slippage, and stops judged on real bars, in Classic and in Reserve. The turns in your report are the ones a trader could actually have seen.

Frequently asked questions

What does a thick or thin Kagi line mean?

The line turns thick, called yang, when it rises above the previous shoulder, the high where the last falling line began. It turns thin, called yin, when it falls below the previous waist, the low where the last rising line began. Traditional Kagi rules buy on the change to yang and sell on the change to yin.

What reversal amount should I use for a Kagi chart?

One that is at least the typical range of the underlying bar and several times your slippage assumption. For daily bars on an index future, one to two average daily ranges is a reasonable start. Use a percentage for long histories or crypto, computed from the price at the time rather than from a later one.

Why does my Kagi strategy enter later in AlphaPrime than on the chart?

Because the chart draws the turn at the shoulder and AlphaPrime acts after the close that confirmed the reversal, which is where the information actually arrived. The delay is the reversal amount's waiting time, and the chart version hid it by placing the trade where the line is drawn.

Does Kagi work for forex and crypto?

Yes. Use a percentage reversal amount for crypto because prices move across wide ranges over a few years, and a fixed amount in pips for forex. The fill and stop rules are the same.