Skip to content
commit-766c8d6756a1

Candlestick

Ordered open-high-low-close observations with conventional increase and decrease treatments.

Purpose
Compare open, high, low, and close values across ordered periods.
Use when
Use for financial or similarly structured ranges where intraperiod movement matters.
Avoid when
Avoid for a single value per period or when a simple trend line communicates the question more directly.
Equivalent data
The adjacent disclosure states increase or decrease in text and preserves exact OHLC and trend values, so meaning never depends on candle color.
Exact OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

PeriodDirectionOpenHighLowClose
Day 1 Increase10011095105
Day 2 Increase105115100112
Day 3 Increase112118108115
Day 4 Decrease115120104108
Day 5 Increase108113105109
Day 6 Increase109116106114
Day 7 Increase114121111119
Usage Example
@candlestick.Candlestick(candlestick.Config{
  Label: "Seven-day stock price",
  Title: "Candlestick Chart",
  SeriesName: "Stock Price",
  Data: []candlestick.Datum{
    {Label: "Day 1", Open: 100, High: 110, Low: 95, Close: 105},
    {Label: "Day 2", Open: 105, High: 115, Low: 100, Close: 112},
    {Label: "Day 3", Open: 112, High: 118, Low: 108, Close: 115},
    {Label: "Day 4", Open: 115, High: 120, Low: 104, Close: 108},
    {Label: "Day 5", Open: 108, High: 113, Low: 105, Close: 109},
    {Label: "Day 6", Open: 109, High: 116, Low: 106, Close: 114},
    {Label: "Day 7", Open: 114, High: 121, Low: 111, Close: 119},
  },
})

Extended basic series

The second upstream construction style adds an eighth daily candle, larger title text, explicit padding, and 800x600 geometry. It remains the same typed component rather than exposing construction functions.

Exact OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

PeriodDirectionOpenHighLowClose
Day 1 Increase10011095105
Day 2 Increase105115100112
Day 3 Increase112118108115
Day 4 Decrease115120104108
Day 5 Increase108113105109
Day 6 Increase109116106114
Day 7 Increase114121111119
Day 8 Increase119125116122
Extended basic series
cfg := sampleBasicCandlestick()
cfg.Label = "Eight-day stock price"
cfg.Data = append(cfg.Data,
  candlestick.Datum{Label: "Day 8", Open: 119, High: 125, Low: 116, Close: 122},
)
cfg.Options = candlestick.Options{
  TitleFontSize: 18,
  YUnit: 1,
  Padding: candlestick.Padding{Top: 20, Right: 20, Bottom: 20, Left: 20},
}
cfg.Width, cfg.Height = 800, 600
@candlestick.Candlestick(cfg)

Multiple aligned series

The pinned upstream comparison keeps three named OHLC populations together and demonstrates filled, traditional, and outline bodies. Exact tables separate each series.

Exact OHLC values for all series

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

Stock A observations (Filled bodies)

PeriodDirectionOpenHighLowClose
Day 1 Increase10011095105
Day 2 Increase105115100112
Day 3 Increase112118108115
Day 4 Decrease115120104108
Day 5 Increase108113105109

Stock B observations (Traditional bodies)

PeriodDirectionOpenHighLowClose
Day 1 Increase150160145155
Day 2 Increase155165150162
Day 3 Increase162168158165
Day 4 Decrease165170154158
Day 5 Increase158163155159

Stock C observations (Outline bodies)

PeriodDirectionOpenHighLowClose
Day 1 Increase200210195205
Day 2 Increase205215200212
Day 3 Increase212218208215
Day 4 Decrease215220204208
Day 5 Increase208213205209
Multiple aligned series
@candlestick.Candlestick(candlestick.Config{
  Label: "Three aligned stock series",
  Series: []candlestick.Series{
    {Name: "Stock A", Data: stockA, BodyStyle: candlestick.BodyStyleFilled},
    {Name: "Stock B", Data: stockB, BodyStyle: candlestick.BodyStyleTraditional},
    {Name: "Stock C", Data: stockC, BodyStyle: candlestick.BodyStyleOutline},
  },
  Options: candlestick.Options{
    YUnit: 1,
    Padding: candlestick.Padding{Top: 20, Right: 20, Bottom: 20, Left: 20},
  },
  Width: 1000, Height: 700,
})

Candle geometry and wicks

Typed width, spacing, wick thickness, chart-level visibility, and per-series visibility options preserve automatic defaults while allowing compact or emphasis treatments.

Exact OHLC values for all series

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

Stock A observations (Filled bodies)

PeriodDirectionOpenHighLowClose
Day 1 Increase10011095105
Day 2 Increase105115100112
Day 3 Increase112118108115
Day 4 Decrease115120104108
Day 5 Increase108113105109

Stock B observations (Traditional bodies)

PeriodDirectionOpenHighLowClose
Day 1 Increase150160145155
Day 2 Increase155165150162
Day 3 Increase162168158165
Day 4 Decrease165170154158
Day 5 Increase158163155159

Stock C observations (Outline bodies)

PeriodDirectionOpenHighLowClose
Day 1 Increase200210195205
Day 2 Increase205215200212
Day 3 Increase212218208215
Day 4 Decrease215220204208
Day 5 Increase208213205209
Candle geometry and wicks
showWicks, hideWicks, seriesGap := true, false, 0.08
cfg := sampleCandlestickMultipleSeries()
cfg.Options.Geometry = candlestick.Geometry{
  CandleWidth: 0.58,
  WickWidth: 2,
  SeriesGap: &seriesGap,
  ShowWicks: &showWicks,
}
cfg.Series[2].ShowWicks = &hideWicks
@candlestick.Candlestick(cfg)

Aggregation

Compare the original ordered candles with fixed-size OHLC windows. The first open, highest high, lowest low, and final close define each aggregated candle.

Exact source and aggregated OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

Source observations

PeriodDirectionOpenHighLowClose
1 Increase10010299101
2 Increase101103100102
3 Increase102105101104
4 Increase104106103105
5 Increase105107104106
6 Increase106108105107
7 Increase107109106108
8 Increase108110107109
9 Increase109111108110
10 Increase110112109111
11 Increase111113110112
12 Increase112114111113
13 Increase113115112114
14 Increase114116113115
15 Increase115117114116

Aggregated observations

PeriodDirectionOpenHighLowClose
1-5 Increase10010799106
6-10 Increase106112105111
11-15 Increase111117110116
Aggregation
@candlestick.Candlestick(candlestick.Config{
  Label: "Candlestick aggregation",
  Title: "1-Minute Candles (Before Aggregation)",
  SeriesName: "1-Minute",
  Data: []candlestick.Datum{
    {Label: "1", Open: 100, High: 102, Low: 99, Close: 101},
    {Label: "2", Open: 101, High: 103, Low: 100, Close: 102},
    {Label: "3", Open: 102, High: 105, Low: 101, Close: 104},
    {Label: "4", Open: 104, High: 106, Low: 103, Close: 105},
    {Label: "5", Open: 105, High: 107, Low: 104, Close: 106},
    {Label: "6", Open: 106, High: 108, Low: 105, Close: 107},
    {Label: "7", Open: 107, High: 109, Low: 106, Close: 108},
    {Label: "8", Open: 108, High: 110, Low: 107, Close: 109},
    {Label: "9", Open: 109, High: 111, Low: 108, Close: 110},
    {Label: "10", Open: 110, High: 112, Low: 109, Close: 111},
    {Label: "11", Open: 111, High: 113, Low: 110, Close: 112},
    {Label: "12", Open: 112, High: 114, Low: 111, Close: 113},
    {Label: "13", Open: 113, High: 115, Low: 112, Close: 114},
    {Label: "14", Open: 114, High: 116, Low: 113, Close: 115},
    {Label: "15", Open: 115, High: 117, Low: 114, Close: 116},
  },
  Aggregation: candlestick.AggregationOptions{
    WindowSize: 5,
    Title: "5-Minute Aggregated Candles",
    SeriesName: "5-Minute",
  },
  Options: candlestick.Options{
    TitleFontSize: 16,
    YUnit: 1,
    Padding: candlestick.Padding{Top: 20, Right: 20, Bottom: 20, Left: 20},
  },
  Width: 1200,
  Height: 800,
})

Bollinger Bands

Twenty OHLC observations with period-five upper, middle, and lower close-price trends. Distinct accessible theme tokens adapt across Goshtoso and AraiHu light and dark modes.

Exact OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

PeriodDirectionOpenHighLowCloseBollinger upperSMA middleBollinger lower
1 Increase10011095105119.046537110.666667102.286797
2 Increase105115100112123.862780113.000000102.137220
3 Increase112118108115129.058697115.400000101.741303
4 Increase115125110120133.459862120.400000107.340138
5 Increase120130115125139.142136125.000000110.857864
6 Increase125135120130144.142136130.000000115.857864
7 Increase130140125135149.142136135.000000120.857864
8 Increase135145130140154.142136140.000000125.857864
9 Increase140150135145154.525200143.600000132.674800
10 Increase145155140150152.540920145.800000139.059080
11 Decrease150160145148150.908132146.600000142.291868
12 Decrease148153143146151.656854146.000000140.343146
13 Decrease146151141144149.656854144.000000138.343146
14 Decrease144149139142147.656854142.000000136.343146
15 Decrease142147137140145.656854140.000000134.343146
16 Decrease140145135138143.656854138.000000132.343146
17 Decrease138143133136141.656854136.000000130.343146
18 Decrease136141131134139.656854134.000000128.343146
19 Decrease134139129132137.472136133.000000128.527864
20 Decrease132137127130135.265986132.000000128.734014
Bollinger Bands
@candlestick.Candlestick(candlestick.Config{
  Label: "Candlestick Chart with Bollinger Bands",
  Title: "Candlestick Chart with Bollinger Bands",
  SeriesName: "Price",
  Data: []candlestick.Datum{
    {Label: "1", Open: 100, High: 110, Low: 95, Close: 105},
    {Label: "2", Open: 105, High: 115, Low: 100, Close: 112},
    {Label: "3", Open: 112, High: 118, Low: 108, Close: 115},
    {Label: "4", Open: 115, High: 125, Low: 110, Close: 120},
    {Label: "5", Open: 120, High: 130, Low: 115, Close: 125},
    {Label: "6", Open: 125, High: 135, Low: 120, Close: 130},
    {Label: "7", Open: 130, High: 140, Low: 125, Close: 135},
    {Label: "8", Open: 135, High: 145, Low: 130, Close: 140},
    {Label: "9", Open: 140, High: 150, Low: 135, Close: 145},
    {Label: "10", Open: 145, High: 155, Low: 140, Close: 150},
    {Label: "11", Open: 150, High: 160, Low: 145, Close: 148},
    {Label: "12", Open: 148, High: 153, Low: 143, Close: 146},
    {Label: "13", Open: 146, High: 151, Low: 141, Close: 144},
    {Label: "14", Open: 144, High: 149, Low: 139, Close: 142},
    {Label: "15", Open: 142, High: 147, Low: 137, Close: 140},
    {Label: "16", Open: 140, High: 145, Low: 135, Close: 138},
    {Label: "17", Open: 138, High: 143, Low: 133, Close: 136},
    {Label: "18", Open: 136, High: 141, Low: 131, Close: 134},
    {Label: "19", Open: 134, High: 139, Low: 129, Close: 132},
    {Label: "20", Open: 132, High: 137, Low: 127, Close: 130},
  },
  TrendLines: []candlestick.TrendLine{
    {Type: candlestick.TrendTypeBollingerUpper, Period: 5},
    {Type: candlestick.TrendTypeSimpleMovingAverage, Period: 5},
    {Type: candlestick.TrendTypeBollingerLower, Period: 5},
  },
  Options: candlestick.Options{
    TitleFontSize: 18,
    YUnit: 1,
    Padding: candlestick.Padding{Top: 20, Right: 20, Bottom: 20, Left: 20},
  },
  Width: 800,
  Height: 600,
})

Presentation overrides

Caller colors or classes may style candle directions and individual trend lines; each mark accepts one override mechanism at a time.

Exact OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

PeriodDirectionOpenHighLowCloseBollinger upperSMA middleBollinger lower
1 Increase10011095105119.046537110.666667102.286797
2 Increase105115100112123.862780113.000000102.137220
3 Increase112118108115129.058697115.400000101.741303
4 Increase115125110120133.459862120.400000107.340138
5 Increase120130115125139.142136125.000000110.857864
6 Increase125135120130144.142136130.000000115.857864
7 Increase130140125135149.142136135.000000120.857864
8 Increase135145130140154.142136140.000000125.857864
9 Increase140150135145154.525200143.600000132.674800
10 Increase145155140150152.540920145.800000139.059080
11 Decrease150160145148150.908132146.600000142.291868
12 Decrease148153143146151.656854146.000000140.343146
13 Decrease146151141144149.656854144.000000138.343146
14 Decrease144149139142147.656854142.000000136.343146
15 Decrease142147137140145.656854140.000000134.343146
16 Decrease140145135138143.656854138.000000132.343146
17 Decrease138143133136141.656854136.000000130.343146
18 Decrease136141131134139.656854134.000000128.343146
19 Decrease134139129132137.472136133.000000128.527864
20 Decrease132137127130135.265986132.000000128.734014
Presentation overrides
cfg := sampleCandlestickBollingerBands()
cfg.Options.Increasing.Color = "#14532d"
cfg.Options.Decreasing.Class = "caller-decreasing-candles"
cfg.TrendLines[0].Color = "#1d4ed8"
cfg.TrendLines[1].Class = "caller-middle-band"
@candlestick.Candlestick(cfg)

Pattern annotations

Show all, core, or bullish patterns while the adjacent table names every detection.

Exact OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

PeriodDirectionOpenHighLowCloseDetected patterns
1 Increase10011095105
2 Increase105108102105.1Doji
3 Decrease10810998107Hammer
4 Decrease107108103104
5 Increase102115101113Bullish Engulfing
6 Increase113125112114Shooting Star, Inverted Hammer
7 Increase114118113117
8 Decrease119120108110Bearish Engulfing
9 Decrease110113107109.9Doji
10 Increase109118108116Bullish Engulfing
Pattern annotations
@candlestick.Candlestick(candlestick.Config{
  Label: "Candlestick patterns",
  Title: "Candlestick Patterns",
  SeriesName: "Stock Price with Patterns",
  Data: []candlestick.Datum{
    {Label: "1", Open: 100, High: 110, Low: 95, Close: 105},
    {Label: "2", Open: 105, High: 108, Low: 102, Close: 105.1},
    {Label: "3", Open: 108, High: 109, Low: 98, Close: 107},
    {Label: "4", Open: 107, High: 108, Low: 103, Close: 104},
    {Label: "5", Open: 102, High: 115, Low: 101, Close: 113},
    {Label: "6", Open: 113, High: 125, Low: 112, Close: 114},
    {Label: "7", Open: 114, High: 118, Low: 113, Close: 117},
    {Label: "8", Open: 119, High: 120, Low: 108, Close: 110},
    {Label: "9", Open: 110, High: 113, Low: 107, Close: 109.9},
    {Label: "10", Open: 109, High: 118, Low: 108, Close: 116},
  },
  Patterns: candlestick.PatternOptions{
    Selection: candlestick.PatternSelectionAll,
    References: []candlestick.CloseReferenceType{
      candlestick.CloseReferenceAverage,
      candlestick.CloseReferenceMinimum,
    },
  },
  Options: candlestick.Options{TitleFontSize: 16, YUnit: 1, Padding: candlestick.Padding{Top: 20, Right: 20, Bottom: 20, Left: 20}},
  Width: 900, Height: 650,
})

Core, bullish, and label variants

Core and bullish selections use the same ten observations, making differences in highlighted patterns easy to compare.

Exact OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

PeriodDirectionOpenHighLowCloseDetected patterns
1 Increase10011095105
2 Increase105108102105.1
3 Decrease10810998107Hammer
4 Decrease107108103104
5 Increase102115101113Bullish Engulfing
6 Increase113125112114Shooting Star
7 Increase114118113117
8 Decrease119120108110Bearish Engulfing
9 Decrease110113107109.9
10 Increase109118108116Bullish Engulfing
Core, bullish, and label variants
cfg.Patterns.Selection = candlestick.PatternSelectionCore
// Other groups: Bullish, Bearish, Reversal, or Trend.
// Enabled selects an explicit ordered subset instead of a group.
cfg.Patterns.DojiThreshold = 0.05
cfg.Patterns.ShadowTolerance = 0.01
cfg.Patterns.ShadowRatio = 2
cfg.Patterns.EngulfingMinSize = 1
cfg.Patterns.PreferLabels = true
cfg.Patterns.Label = candlestick.PatternLabelStyle{
  Text: candlestick.PatternLabelTextNameWithCount,
  Color: "#ffffff", BackgroundColor: "#1d4ed8", FontSize: 8, CornerRadius: 2,
}
@candlestick.Candlestick(cfg)

Preferred pattern labels

A selected pattern label can show its first name and count with explicit text and background colors.

Exact OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

PeriodDirectionOpenHighLowCloseDetected patterns
1 Increase10011095105
2 Increase105108102105.1Doji
3 Decrease10810998107Hammer
4 Decrease107108103104
5 Increase102115101113Bullish Engulfing
6 Increase113125112114Shooting Star, Inverted Hammer
7 Increase114118113117
8 Decrease119120108110Bearish Engulfing
9 Decrease110113107109.9Doji
10 Increase109118108116Bullish Engulfing
Preferred pattern labels
cfg.Patterns.Selection = candlestick.PatternSelectionCore
// Other groups: Bullish, Bearish, Reversal, or Trend.
// Enabled selects an explicit ordered subset instead of a group.
cfg.Patterns.DojiThreshold = 0.05
cfg.Patterns.ShadowTolerance = 0.01
cfg.Patterns.ShadowRatio = 2
cfg.Patterns.EngulfingMinSize = 1
cfg.Patterns.PreferLabels = true
cfg.Patterns.Label = candlestick.PatternLabelStyle{
  Text: candlestick.PatternLabelTextNameWithCount,
  Color: "#ffffff", BackgroundColor: "#1d4ed8", FontSize: 8, CornerRadius: 2,
}
@candlestick.Candlestick(cfg)

Bullish patterns

Bullish-only selection keeps only the bullish pattern vocabulary while preserving source order and exact values.

Exact OHLC values

Increase means close is greater than or equal to open; decrease means close is below open. Detected patterns are named in text and do not depend on color.

PeriodDirectionOpenHighLowCloseDetected patterns
1 Increase10011095105
2 Increase105108102105.1
3 Decrease10810998107Hammer
4 Decrease107108103104
5 Increase102115101113Bullish Engulfing
6 Increase113125112114Inverted Hammer
7 Increase114118113117
8 Decrease119120108110
9 Decrease110113107109.9
10 Increase109118108116Bullish Engulfing
Bullish patterns
cfg.Patterns.Selection = candlestick.PatternSelectionCore
// Other groups: Bullish, Bearish, Reversal, or Trend.
// Enabled selects an explicit ordered subset instead of a group.
cfg.Patterns.DojiThreshold = 0.05
cfg.Patterns.ShadowTolerance = 0.01
cfg.Patterns.ShadowRatio = 2
cfg.Patterns.EngulfingMinSize = 1
cfg.Patterns.PreferLabels = true
cfg.Patterns.Label = candlestick.PatternLabelStyle{
  Text: candlestick.PatternLabelTextNameWithCount,
  Color: "#ffffff", BackgroundColor: "#1d4ed8", FontSize: 8, CornerRadius: 2,
}
@candlestick.Candlestick(cfg)

Static/vector behavior

Candlestick renders inline SVG on the server, follows Goshtoso and AraiHu tokens in light and dark mode, remains useful in print or without JavaScript, and provides resolved SVG plus opaque or transparent PNG download through the shared wrapper. Use the exact tables for comparisons that cannot be judged from geometry; shared chart controls and chart modes guides document lifecycle and delivery choices.

Go API

v0.0.1

The examples above cover behavior and composition. pkg.go.dev is the canonical reference for exported types, functions, methods, and Go documentation.

github.com/araihu/goshtoso-charts/components/candlestick

Enabled, disabled, hidden, and omitted wrapper behavior, controls, export, and client transitions are shared by every chart. Review chart controls, then compare static/vector and interactive capabilities.

Open v0.0.1 API