Yamagishi Complexity Torus LabYamagishi Lab

[F020] Candlestick Shapes Belong to the Way the Bars Were Cut

Abstract

This paper asks whether candlestick shapes belong to the market or to the way the bars were cut — the answer is that they belong to the cut. It claims neither a new mathematical theorem nor a new law.

First, the frequency of four shapes (engulfing, inside bar, pin bar, doji) moves from changing the bar size alone. The median largest-to-smallest ratio by instrument and shape is 1.1745, the maximum 1.5721. A pin bar appears 67.6854 times per thousand five-minute bars and 45.7459 times per thousand four-hour bars (Section 3).

Second, and this is the core of the paper, whether a bar engulfs the previous one is decided by whether this open lies inside the previous close. The median absolute distance between those two is 0.1111 of the spread (median), ranging from 0.0417 to 0.1667 (Section 4).

Third, the share where that distance is exactly zero has a median of 1.3732%. So whether a bar engulfs is sorted almost evenly by a quantity about a tenth of the spread (Section 4).

Fourth, the ratio against a synthetic random walk departs systematically by shape: 0.4986 to 0.5107 for engulfing, 1.4474 to 1.6656 for inside bars, 0.5886 to 0.6420 for pin bars and 1.3077 to 1.3894 for dojis. 0 of 16 cells fall between 0.8 and 1.25 (Section 5).

Fifth, ★ the departure for engulfing is explained by how the baseline is built. On a synthetic random walk the open equals the previous close exactly, so the condition is satisfied automatically. That baseline cannot be used for shapes that involve the open. This paper measured that before writing it (Sections 4 and 5).

Sixth, the directional information over 24 hours from the bar carrying the shape reaches a daily t of 2 in absolute value in 2 of 16 cells (chance gives about 0.7). Changing the bar size moves the median D from −1.4472 to +0.5823 pips, sign included (Sections 6 and 7).

Scope of this paper (scope note): No new mathematical theorem and no new law is claimed — the definitions of candlestick shapes and random walks are known. No particular product or proponent is discussed — no real course, author, or vendor is the subject here, and none is named. What is treated is the public shapes themselves. Trading is not discussed — what is measured is occurrence rates and directional information, not trading performance including commissions, fills and money management. The scope is intraday and a small number of instruments — four series over three years. Monthly time-series momentum (dozens of markets, holding one to twelve months) is documented in the literature, and this paper does not contradict it. One set of definitions is fixed — a pin bar's tail is 2.0 times the body or more with the other tail 0.5 times or less, and a doji's body is 10% of the range or less. Other thresholds give other frequencies (Section 9). ★ The synthetic baseline cannot be used for shapes that involve the open — on the synthetic series the open equals the previous close exactly. This paper measured that before writing it (Section 4). The overlap is not removed — the horizon is 24 hours. No forecast is claimed. Relation to earlier papers: F016 compared multi-swing patterns (double tops and so on) against a synthetic random walk — this paper applies the same move to the shapes of one or two bars. What is added here is showing that the frequency moves with the bar size, placing the distance used to judge engulfing beside the spread, and measuring and stating where the baseline cannot be used.

1. Notation and the question

Shapes made of one or two candles carry names.

ShapeDefinition (the buy direction)What is said about it
Engulfingthe previous bar is down, this one up, and this body engulfs the previous onebuyers swallowed the sellers
Inside barthis bar's high and low fall inside the previous bar'sthe momentum stopped
Pin bara long lower tail and a short upper oneprice was bought up from below
Dojian extremely small bodyhesitation, a turn

Observation 1.1: each can be judged the moment its bar completes. No look-ahead. That part is correct.

Observation 1.2: but a shape depends on how the bars are cut. The same price movement makes different shapes cut at five minutes or at four hours. "The sellers ran out of strength" does not mention the cut.

Observation 1.3: the question settles by measuring three things. Does the frequency move with the bar size? Does it appear on a synthetic random walk? And how small is the difference being used to judge?

Question: do candlestick shapes belong to the market, or to the way the bars were cut?

2. Writing the quantity and the design in advance

Design (declared before running and unchanged at run time)

ItemDecision
Bar sizesfive-minute, one-hour, four-hour (mid price, completed bars only)
Engulfingthe previous bar down and this one up, this close at or above the previous open, this open at or below the previous close, and this body larger
Inside barthis bar's high and low fall inside the previous bar's (direction opposite the previous bar's colour)
Pin barthe lower tail is 2.0 times the body or more and the upper tail 0.5 times or less
Dojithe body is 10% of the range or less (direction opposite the previous bar's colour)
Directional informationa signal on the bar carrying the shape, over the next 24 hours (pips)
Baselinesynthetic series random down to the movement inside each bar (10 realisations)
InstrumentsUSDJPY, EURUSD, GBPUSD, XAUUSD
Period2019–2024. Evaluation 2022–2024

Observation 2.1: the sell side uses the same definition with the signs reversed. Counting only buys would be dragged by which way the period went.

Observation 2.2: the horizon is held at 24 hours across bar sizes. Without that, "the shape worked" cannot be separated from "a different span was looked at".

Observation 2.3: ★ the synthetic baseline turns out to have a problem. Section 4 measures it and Section 5 says how far it can be used.

In the evaluation period the bar counts are, for USDJPY, 214,291 five-minute, 17,865 one-hour and 4,812 four-hour; for EURUSD 214,605, 17,891, 4,822; for GBPUSD 214,370, 17,874, 4,818; and for XAUUSD 209,799, 17,495, 4,735.

3. The frequency of the shapes moves with the bar size

Calculation 3.1 Occurrences per thousand bars (evaluation period)

InstrumentShape5m1h4hLargest ÷ smallest
USDJPYengulfing126.8789127.7918133.00081.0483
USDJPYinside bar155.0042167.5343193.26681.2468
USDJPYpin bar67.627753.680443.01751.5721
USDJPYdoji100.2095109.0960109.31011.0908
EURUSDengulfing113.6041125.6498118.41561.1060
EURUSDinside bar148.0534153.0378181.25261.2242
EURUSDpin bar67.743149.186748.11281.4080
EURUSDdoji96.2419105.3043101.61761.0942
GBPUSDengulfing114.9694124.7622129.30681.1247
GBPUSDinside bar145.8740145.5746178.91241.2290
GBPUSDpin bar67.896653.485543.37901.5652
GBPUSDdoji100.7837102.6631103.77751.0297
XAUUSDengulfing120.8204126.8362118.90181.0667
XAUUSDinside bar140.4058162.4464206.54701.4711
XAUUSDpin bar61.754351.786248.57441.2713
XAUUSDdoji98.0748105.2301107.70861.0982

Calculation 3.2 Medians by shape and bar size (per thousand bars)

Shape5m1h4h
Engulfing117.8949126.2430124.1043
Inside bar146.9637157.7421187.2597
Pin bar67.685452.635945.7459
Doji99.1422105.2672105.7430

Observation 3.3: the median largest-to-smallest ratio across bar sizes is 1.1745, ranging from 1.0297 to 1.5721.

Observation 3.4: pin bars move most with the bar size. 67.6854 per thousand five-minute bars against 45.7459 per thousand four-hour bars: the finer the bar, the more of them.

Observation 3.5: inside bars go the other way. 146.9637 on five-minute bars and 187.2597 on four-hour ones: the coarser the bar, the more of them.

Observation 3.6: ★ since the direction reverses between shapes, this cannot be explained by "the market changed". The bars are built from the same period and the same prices. What moves is only the cut.

Figure 2 Changing the bar size moves the frequency

Figure 2: occurrences per thousand bars at three bar sizes, one panel per instrument. The direction across bar sizes reverses between shapes.

4. Engulfing is decided by a tenth of the spread — this is the separator

Calculation 4.1 The distance between this open and the previous close (evaluation period)

InstrumentBar sizeMedian absolute distance (pips)Median spreadDistance ÷ spreadShare exactly zero
USDJPY5m0.05000.60000.083310.2127%
USDJPY1h0.10000.60000.16679.6781%
USDJPY4h0.10000.60000.16679.4971%
EURUSD5m0.05000.30000.16671.2246%
EURUSD1h0.05000.30000.16671.9507%
EURUSD4h0.05000.30000.16672.1360%
GBPUSD5m0.05000.90000.05561.0473%
GBPUSD1h0.10000.90000.11111.5218%
GBPUSD4h0.10000.90000.11111.1416%
XAUUSD5m0.15003.54000.04240.5529%
XAUUSD1h0.15003.57000.04200.8059%
XAUUSD4h0.15003.60000.04170.8448%

Observation 4.2: ★ the median of that distance divided by the spread is 0.1111, ranging from 0.0417 to 0.1667.

Observation 4.3: ★ engulfing is decided by the sign of that distance. So whether a bar engulfs is sorted by a quantity about a tenth of the spread.

Observation 4.4: the share where the distance is exactly zero has a median of 1.3732%. For USDJPY it reaches 9.4971% to 10.2127%. USDJPY is high because its price grid is coarse relative to one pip.

Observation 4.5: ★ so "buyers swallowed the sellers" rides on the sign of a difference an order of magnitude below the spread. That difference is smaller than the width at which one can transact.

Observation 4.6: ★ and on the synthetic series that distance is exactly zero. The bars are built from a continuous walk, so the open equals the previous close exactly. The engulfing condition is therefore satisfied automatically and the frequency jumps. That baseline cannot be used for shapes that involve the open.

5. The baseline — where it can be used and where it cannot

Calculation 5.1 Against the synthetic random walk (hourly, 10 realisations, per thousand bars)

InstrumentShapeMeasuredRandom walkRatio
USDJPYengulfing127.7918250.23230.5107
USDJPYinside bar167.5343100.58771.6656
USDJPYpin bar53.680483.61040.6420
USDJPYdoji109.096078.52231.3894
EURUSDengulfing125.6498250.20400.5022
EURUSDinside bar153.0378100.57011.5217
EURUSDpin bar49.186783.57270.5886
EURUSDdoji105.304378.49761.3415
GBPUSDengulfing124.7622250.23500.4986
GBPUSDinside bar145.5746100.57631.4474
GBPUSDpin bar53.485583.60750.6397
GBPUSDdoji102.663178.50511.3077
XAUUSDengulfing126.8362250.25440.5068
XAUUSDinside bar162.4464100.38871.6182
XAUUSDpin bar51.786283.76110.6183
XAUUSDdoji105.230178.62251.3384

Observation 5.2: the median measured-to-random ratio is 0.9749, but the range runs from 0.4986 to 1.6656. 0 of 16 cells fall between 0.8 and 1.25.

Observation 5.3: ★ the median being near one is an accident. The departures are systematic by shape, and taking their average is all the median did. A median must not be read alone.

Observation 5.4: ★ engulfing appears 250.2040 to 250.2544 times per thousand on the synthetic series — exactly twice the measurement. As Section 4 showed, the open equals the previous close exactly, so the condition is satisfied automatically. That ratio says nothing about the market; it speaks about how the baseline was built.

Observation 5.5: the doji also uses the open (the body is close minus open) and is distorted the same way. That its ratio stays between 1.3077 and 1.3894 is because the distortion is constant.

Observation 5.6: ★ what can be used are the shapes that do not involve the open. An inside bar uses only highs and lows; a pin bar uses only ratios among one bar's four values. Inside bars are 1.4474 to 1.6656 times more frequent in the measurement, pin bars 0.5886 to 0.6420 times less. Neither matches the random walk, but that gap does not mean the shape carries meaning: real bars are not a continuous walk and the size of the move changes by session.

Observation 5.7: ★ this paper does not conclude that "the shapes appear as often as on a random walk". ★ What it can conclude is that the frequency depends strongly on both the cut (Section 3) and the construction of the baseline (Section 4).

Figure 1 The shapes appear just as often on a synthetic random walk (hourly)

Figure 1: occurrences per thousand bars for the four shapes, by instrument. The dark bars (measured) and the light ones (random walk) depart systematically by shape.

6. The move after the bar carrying the shape

Calculation 6.1 The move in the direction the shape predicts (hourly, 24 hours ahead, evaluation period)

InstrumentShapeCountD (pips)Dd (daily mean)Daily tSpreadBuy/sell
XAUUSDengulfing2,2191.57602.10870.473.571115/1099
XAUUSDinside bar2,8421.90630.72800.173.571423/1415
XAUUSDpin bar906−1.25163.03190.433.57508/398
XAUUSDdoji1,841−4.9772−6.9927−1.433.54874/964
GBPUSDdoji1,8350.7914−0.3688−0.170.90900/930

Observation 6.2: the median D by shape is +1.1849 for engulfing, +0.5323 for inside bars, −0.7979 for pin bars and +0.0544 pips for dojis, against a median spread of 0.7500 pips.

Observation 6.3: the daily t reaches 2 in absolute value in 2 of 16 cells. Chance gives about 0.7, so somewhat more.

Observation 6.4: the two that look significant are one engulfing and one pin bar. This paper does not claim them. The horizon is 24 hours and the observations overlap.

Observation 6.5: buys and sells are nearly equal (1423/1415 for XAUUSD inside bars). Only pin bars are skewed (508/398). Tails are not symmetric up and down, and that itself contains which way the period went.

7. Changing the bar size moves the directional information too

Calculation 7.1 Same shape, same 24 hours, only the bar size changed (evaluation period, pips)

InstrumentShape5m D5m t1h D1h t4h D4h t
USDJPYengulfing−0.1704−1.194.84173.00−0.41550.20
USDJPYinside bar−0.6832−2.31−1.9012−0.58−3.8545−0.71
USDJPYpin bar1.02380.119.88773.16−0.7374−0.47
USDJPYdoji−0.9764−0.22−0.68260.121.70150.22
EURUSDengulfing−0.6851−1.430.3731−0.26−2.5657−1.07
EURUSDinside bar0.27780.771.04281.72−4.5383−2.04
GBPUSDengulfing0.0665−0.480.79380.70−5.4092−2.05
GBPUSDpin bar−0.6882−0.27−0.34420.141.99330.58
XAUUSDpin bar−3.5413−2.89−1.25160.43−11.8705−1.14
XAUUSDinside bar1.1832−0.271.90630.1710.80591.92

Observation 7.2: the median D by bar size is −0.2947 on five-minute bars, +0.5823 on hourly and −1.4472 pips on four-hour. The sign changes with the bar size.

Observation 7.3: the daily t reaches 2 in absolute value in 2 of 16 cells at all three bar sizes, against about 0.7 by chance. No bar size produces more than another.

Observation 7.4: ★ USDJPY's pin bar gives D = +9.8877 (t 3.16) on hourly bars and −0.7374 (t −0.47) on four-hour ones. Same shape, same period, same horizon — only the bar size changed, and the sign changed with it.

Observation 7.5: ★ so "this shape works" means nothing without stating the bar size. And trying three bar sizes guarantees that one of them looks good.

8. Splitting by session

Design: five non-overlapping bins in Coordinated Universal Time. The signal is the hourly engulfing bar.

Calculation 8.1 Directional information in each of the five bins (evaluation period)

InstrumentTokyo 0–7London 7–12Overlap 12–16NY late 16–21Night 21–24
USDJPY4.85 (t 2.29)3.47 (t 0.92)4.57 (t 0.71)7.37 (t 1.58)3.71 (t 0.84)
EURUSD−1.80 (t −1.26)3.50 (t 1.55)0.55 (t 0.23)0.34 (t 0.28)0.83 (t 0.48)
GBPUSD−1.46 (t −0.81)2.54 (t 1.08)0.10 (t 0.61)0.95 (t 0.72)4.79 (t 1.21)
XAUUSD−3.17 (t −0.59)6.77 (t 0.93)3.63 (t 0.49)9.32 (t 1.53)−18.35 (t −1.23)

Observation 8.2: the daily t reaches 2 in absolute value in 1 of 20 cells. Chance gives about 0.9, so about what chance gives.

Observation 8.3: the one that looks significant is USDJPY in the Tokyo bin (4.85, t 2.29). This paper does not claim it.

Observation 8.4: USDJPY is positive in all five bins. That may be a restatement of the instrument having risen over the period. The drift is not separated here.

9. Limitations

  1. ★ The synthetic baseline cannot be used for shapes that involve the open. On the synthetic series the open equals the previous close exactly, which distorts the frequency of engulfing and doji. This paper measured that before writing it, but did not build a corrected baseline. That is the chief limitation.
  2. One set of definitions is fixed, with 2.0 and 0.5 for the pin bar and 10% for the doji. Other thresholds give other frequencies. Sections 3 (movement with the bar size) and 4 (the distance being below the spread) do not depend on the thresholds.
  3. ★ Why inside bars and pin bars do not match the random walk is not explained. Real bars are not a continuous walk and the size of the move changes by session. That effect is not separated.
  4. The overlap is not removed. The horizon is 24 hours, so the daily t in Sections 6 and 7 is inflated.
  5. The drift is not separated. USDJPY being positive in all five bins in Section 8 contains which way the period went.
  6. The synthetic baseline uses independent normal increments. Volatility clustering is not included.
  7. Four instruments over three years. Nothing is said about other markets or other periods.

Conclusion

Candlestick shapes come with names and stories: buyers swallowed the sellers, price was bought up from below.

But engulfing is decided by whether this open lies inside the previous close — and the median distance between those two is 0.1111 of the spread. The share where it is exactly zero has a median of 1.3732%, reaching 10.2127% for USDJPY.

Whether anything was swallowed is decided by the sign of a quantity an order of magnitude below the width at which one can transact.

The frequency moves by a median of 1.1745 times from changing the bar size alone, with pin bars more frequent on fine bars and inside bars more frequent on coarse ones. Since the direction reverses between shapes, the market cannot explain it.

And the ratio against a synthetic random walk departs systematically by shape, from 0.4986 to 1.6656, with 0 of 16 cells falling between 0.8 and 1.25. The departure for engulfing is explained by how the baseline is built; the departures for inside bars and pin bars are not explained.

★ This paper does not conclude that the shapes appear as often as on a random walk. What it can conclude is that the frequency depends strongly on both the cut and the construction of the baseline.

The directional information reaches a daily t of 2 in absolute value in 2 of 16 cells (chance gives 0.7), and changing the bar size moves the median D from −1.4472 to +0.5823 pips, sign included. "This shape works" means nothing without stating the bar size.

Data and reproduction

DataCurrency ticks from Dukascopy (agreement to the millisecond, bid and ask, verified from 2019 onward). Gold from Dukascopy
Period2019–2024 (six years). Evaluation 2022–2024
InstrumentsUSDJPY, EURUSD, GBPUSD, XAUUSD
BarsFive-minute, one-hour and four-hour. Mid price, completed bars only. Bars with no ticks are not created
ShapesEngulfing, inside bar, pin bar (2.0 and 0.5), doji (10%)
Verification検算/F020.py (with --zu it also writes the figures). Every number in the text is taken from 検算/F020_output.txt
Figures図/F020_zu1, 図/F020_zu2 (png, svg, English versions)
Random seedsFixed at 0–9. Re-running gives the same values
Audit of the foundation_ツール/audit_bars.py (look-ahead in the bars, daylight saving, the day boundary). The record is _土台の検査.txt

References

  • Yamagishi, Y. (2026). Chart Patterns Appear Just as Often on a Synthetic Random Walk [F016]. Zenodo. 10.5281/zenodo.22891793

Reference

Yamagishi, Y. (2026). Candlestick Shapes Belong to the Way the Bars Were Cut [F020]. Zenodo.
DOI: 10.5281/zenodo.22891997
YOI: https://www.yamagishiyuuki.com/yoi/F020
ORCID: 0009-0006-8587-3450

PDF (English) · PDF (Japanese) · Date proof of the English PDF (OpenTimestamps .ots) · SHA256SUMS

The record page for this paper (in Japanese, with the PDFs in each language and the date proof): YOI F020. This paper is a preprint and has not been peer reviewed.