ThreeLineBreakBars
Line-break chart segments — a new line per close extreme, reversing only on a break of the last three lines.
Quick reference
| Field | Value |
|---|---|
| Family | Alt-Chart Bars |
| Trait | BarBuilder (not Indicator) |
| Input type | Candle |
| Output type | Vec<LineBreakBar> (0 or 1 line per candle) |
| Bar element | LineBreakBar { open, close, direction: i8 } |
| Default parameters | (lines = 3) |
| Warmup | none (seeds on the first candle) |
| Interpretation | Each line = one confirmed leg of the trend. |
Formula
seed: reference = first close
first line: first move up/down draws line 1
up-trend: close > last line's top -> new up line (continuation)
close < lowest low of last `lines` lines -> new down line (reversal)
down-trend: symmetricA line-break chart draws a new line in the trend direction whenever the close makes a new extreme, and reverses only when the close breaks the extreme of the previous lines lines (three by default). A pullback that fails to exceed the last three lines is ignored, so the chart isolates meaningful reversals and filters noise. Source: crates/wickra-core/src/indicators/three_line_break_bars.rs.
This is the bar-builder counterpart of the ThreeLineBreak indicator: the indicator streams the current line state as a value, while this builder emits each completed line as a LineBreakBar so you can reconstruct the full chart.
Parameters
| Name | Type | Default | Valid range | Source | Description |
|---|---|---|---|---|---|
lines | usize | 3 | >= 1 | three_line_break_bars.rs:62 | Lines a reversal must break (3 = classic three-line break). 0 errors with Error::PeriodZero. |
The lines and tracked getters expose the configuration and the count of recent lines held for the reversal test.
Inputs / Outputs
From crates/wickra-core/src/indicators/three_line_break_bars.rs:
use wickra::{BarBuilder, Candle, LineBreakBar, ThreeLineBreakBars};
// ThreeLineBreakBars: Input = Candle, Output = Vec<LineBreakBar>
const _: fn(&mut ThreeLineBreakBars, Candle) -> Vec<LineBreakBar> =
<ThreeLineBreakBars as BarBuilder>::update;A Candle in, a Vec<LineBreakBar> out (empty until a line forms). Bindings are close-driven: Python update(close) -> list[tuple]; Node update(close) -> LineBreakBar[]. No warmupPeriod/isReady.
Signed ±1 encoding
The direction field is +1 for a rising line (a new high extended the up-trend, or an up-reversal) and -1 for a falling line. The open is the previous line's far edge; the close is the new close that drew the line.
Edge cases
- Seed then first line. The first candle seeds; the first move draws line 1 (
seed_then_first_linepins this). - Continuation. A new high extends the up-trend with another up line (
new_high_extends_up_linepins this). - No break. A pullback inside the last three lines prints nothing (
small_pullback_prints_nothingpins this). - Reversal. A close below the lowest low of the last three lines reverses (
reversal_breaks_three_linespins this). - Reset.
reset()clears the seed and tracked lines (reset_clears_state). - Batch.
batchconcatenates completed lines; length is data-dependent (batch_concatenates_completed_linespins this).
Examples
Rust
use wickra::{BarBuilder, Candle, ThreeLineBreakBars};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let flat = |p: f64| Candle::new(p, p, p, p, 1.0, 0).unwrap();
let mut bars = ThreeLineBreakBars::new(3)?;
bars.update(flat(10.0)); // seed
let first = bars.update(flat(11.0)); // first up line
println!("{} {}", first[0].direction, first[0].close); // 1 11
Ok(())
}Output:
1 11Python
import wickra as ta
bars = ta.ThreeLineBreakBars(3)
bars.update(10.0) # seed -> []
print(bars.update(11.0)) # [(10.0, 11.0, 1)]Node
const ta = require('wickra');
const bars = new ta.ThreeLineBreakBars(3);
bars.update(10.0); // seed
console.log(bars.update(11.0)[0].direction); // 1Streaming
use wickra::{BarBuilder, Candle, ThreeLineBreakBars};
let mut bars = ThreeLineBreakBars::new(3).unwrap();
let feed: Vec<Candle> = Vec::new(); // your live stream
for candle in feed {
for line in bars.update(candle) {
// a direction flip marks a confirmed three-line-break reversal
}
}batch is equivalent to replaying update candle-by-candle and concatenating (batch_concatenates_completed_lines pins this).
Interpretation
- Noise filter. Because reversals require breaking three lines, choppy ranges produce few or no lines — the chart only "moves" on confirmed trends.
- Reversal signal. A change in
directionis the classic three-line-break trade trigger; raiselinesfor a stricter (slower) filter. - Pair with the indicator. Use
ThreeLineBreakwhen you need a streaming trend state, and this builder when you need the line geometry for charting or pattern analysis.
Common pitfalls
- Close-driven. Lines use close prices, not intrabar high/low — intrabar spikes do not draw lines.
- Lookback ramp-up. With fewer than
lineslines drawn, reversals test against the lines available so far. - Not an
Indicator. No warmup, emits aVec, cannot join aChain.
References
Nison, S. (1994), Beyond Candlesticks — three-line-break charts; a staple of the Japanese charting tradition.
See also
- Indicator-ThreeLineBreak — the streaming indicator form.
- Indicator-RenkoBars — fixed-brick alternative chart.
- Indicator-KagiBars — reversal-amount line segments.
- Indicators-Overview — the full taxonomy.