Fibonacci Entry Bands
source = hlc3 | length = 21 | atr_length = 14 | use_atr = true | tp_aggressiveness = low Overview
Fibonacci Entry Bands is not just a volatility envelope. It builds a smoothed basis line from the chosen price source, measures volatility with either ATR or rolling standard deviation, and then projects multiple Fibonacci expansion distances around that basis. Those upper and lower ladders become the context for entry signals, rejection markers, bounce markers, and take-profit bands.
The result is a wide output surface instead of a single line. Alongside the basis and trend state, the indicator emits four upper bands, four lower bands, separate long and short take-profit bands, plus boolean-style signal series for entries, rejections, and bounces. The default path uses `hlc3`, a basis length of `21`, ATR spacing, and the conservative `low` take-profit aggressiveness profile.
Defaults: Fibonacci Entry Bands uses `source = "hlc3"`, `length = 21`, `atr_length = 14`, `use_atr = true`, and `tp_aggressiveness = "low"`.
Implementation Examples
Compute the basis, Fibonacci band ladder, and signal markers from OHLC slices or candle data.
use vector_ta::indicators::fibonacci_entry_bands::{
fibonacci_entry_bands,
FibonacciEntryBandsInput,
FibonacciEntryBandsParams,
};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};
let open = vec![100.0, 100.5, 101.0, 101.3, 101.9];
let high = vec![101.1, 101.4, 101.8, 102.2, 102.6];
let low = vec![99.7, 100.1, 100.6, 101.0, 101.4];
let close = vec![100.6, 101.0, 101.5, 101.8, 102.3];
let output = fibonacci_entry_bands(&FibonacciEntryBandsInput::from_slices(
&open,
&high,
&low,
&close,
FibonacciEntryBandsParams {
source: Some("hlc3".to_string()),
length: Some(21),
atr_length: Some(14),
use_atr: Some(true),
tp_aggressiveness: Some("low".to_string()),
},
))?;
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let candle_output = fibonacci_entry_bands(&FibonacciEntryBandsInput::with_default_candles(&candles))?;
println!("basis = {:?}", output.basis.last());
println!("trend = {:?}", candle_output.trend.last());
println!("tp bands = {:?} / {:?}", candle_output.tp_long_band.last(), candle_output.tp_short_band.last()); API Reference
Input Methods ▼
// From candles
FibonacciEntryBandsInput::from_candles(&Candles, FibonacciEntryBandsParams)
-> FibonacciEntryBandsInput
// From OHLC slices
FibonacciEntryBandsInput::from_slices(
&[f64],
&[f64],
&[f64],
&[f64],
FibonacciEntryBandsParams,
) -> FibonacciEntryBandsInput
// From candles with default parameters
FibonacciEntryBandsInput::with_default_candles(&Candles)
-> FibonacciEntryBandsInput Parameters Structure ▼
pub struct FibonacciEntryBandsParams {
pub source: Option<String>, // default "hlc3"
pub length: Option<usize>, // default 21
pub atr_length: Option<usize>, // default 14
pub use_atr: Option<bool>, // default true
pub tp_aggressiveness: Option<String>, // default "low"
} Output Structure ▼
pub struct FibonacciEntryBandsOutput {
pub basis: Vec<f64>,
pub trend: Vec<f64>,
pub upper_0618: Vec<f64>,
pub upper_1000: Vec<f64>,
pub upper_1618: Vec<f64>,
pub upper_2618: Vec<f64>,
pub lower_0618: Vec<f64>,
pub lower_1000: Vec<f64>,
pub lower_1618: Vec<f64>,
pub lower_2618: Vec<f64>,
pub tp_long_band: Vec<f64>,
pub tp_short_band: Vec<f64>,
pub long_entry: Vec<f64>,
pub short_entry: Vec<f64>,
pub rejection_long: Vec<f64>,
pub rejection_short: Vec<f64>,
pub long_bounce: Vec<f64>,
pub short_bounce: Vec<f64>,
} Validation, Warmup & NaNs ▼
- All four OHLC inputs must be non-empty and length-matched.
sourcemust be one ofopen,high,low,close,hl2,hlc3,ohlc4, orhlcc4.tp_aggressivenessmust be one oflow,medium, orhigh.lengthandatr_lengthmust be positive and valid for the supplied data length.- The stream resets on invalid bars and reports its required warmup through
get_warmup_period(). - When
use_atr = true, band spacing comes from ATR; otherwise it comes from rolling standard deviation of the selected source. - Many signal series are sparse by design, with `1.0` only on matching events and `0.0` or `NaN` elsewhere.
Builder, Streaming & Batch APIs ▼
// Builder
FibonacciEntryBandsBuilder::new()
.source(&str)?
.length(usize)
.atr_length(usize)
.use_atr(bool)
.tp_aggressiveness(&str)?
.kernel(Kernel)
.apply(&Candles)
FibonacciEntryBandsBuilder::new()
.apply_slices(&[f64], &[f64], &[f64], &[f64])
FibonacciEntryBandsBuilder::new()
.into_stream()
// Stream
FibonacciEntryBandsStream::try_new(FibonacciEntryBandsParams)
FibonacciEntryBandsStream::update(f64, f64, f64, f64)
-> Option<FibonacciEntryBandsPoint>
FibonacciEntryBandsStream::reset()
FibonacciEntryBandsStream::get_warmup_period() -> usize
// Batch
FibonacciEntryBandsBatchBuilder::new()
.length_range(start, end, step)
.atr_length_range(start, end, step)
.source(&str)
.use_atr(bool)
.tp_aggressiveness(&str)
.kernel(Kernel)
.apply_slices(&[f64], &[f64], &[f64], &[f64])
FibonacciEntryBandsBatchBuilder::new()
.apply_candles(&Candles) Error Handling ▼
pub enum FibonacciEntryBandsError {
EmptyInputData,
AllValuesNaN,
InconsistentSliceLengths { open_len: usize, high_len: usize, low_len: usize, close_len: usize },
InvalidLength { length: usize, data_len: usize },
InvalidAtrLength { atr_length: usize, data_len: usize },
InvalidSource { source_name: String },
InvalidTpAggressiveness { tp_aggressiveness: String },
NotEnoughValidData { needed: usize, valid: usize },
OutputLengthMismatch { expected: usize },
InvalidRange { start: String, end: String, step: String },
InvalidKernelForBatch(Kernel),
} Python Bindings
Python exposes dict-returning scalar and streaming paths plus a batch function. The scalar function returns one dictionary with the full band ladder and signal set. The stream returns either `None` or a point-shaped dictionary for the latest bar. Batch returns matrices for every output plus the per-row parameter metadata.
import numpy as np
from vector_ta import fibonacci_entry_bands, fibonacci_entry_bands_batch, FibonacciEntryBandsStream
result = fibonacci_entry_bands(
np.asarray(open_values, dtype=np.float64),
np.asarray(high_values, dtype=np.float64),
np.asarray(low_values, dtype=np.float64),
np.asarray(close_values, dtype=np.float64),
source="hlc3",
length=21,
atr_length=14,
use_atr=True,
tp_aggressiveness="low",
kernel="auto",
)
print(result["basis"], result["upper_1618"], result["long_entry"])
stream = FibonacciEntryBandsStream("hlc3", 21, 14, True, "low")
print(stream.warmup_period)
print(stream.update(open_values[-1], high_values[-1], low_values[-1], close_values[-1]))
batch = fibonacci_entry_bands_batch(
np.asarray(open_values, dtype=np.float64),
np.asarray(high_values, dtype=np.float64),
np.asarray(low_values, dtype=np.float64),
np.asarray(close_values, dtype=np.float64),
length_range=(21, 34, 13),
atr_length_range=(14, 21, 7),
source="hlc3",
use_atr=True,
tp_aggressiveness="low",
kernel="auto",
)
print(batch["basis"].shape, batch["long_entry"].shape)
print(batch["lengths"], batch["atr_lengths"], batch["sources"], batch["tp_aggressiveness_values"]) JavaScript/WASM Bindings
The WASM layer exposes object-returning scalar and batch wrappers plus low-level in-place exports. Both the scalar and batch JavaScript paths preserve the full set of basis, band, and signal fields, with batch also returning row metadata and parameter lists.
import init, {
fibonacci_entry_bands_js,
fibonacci_entry_bands_batch_js,
} from "/pkg/vector_ta.js";
await init();
const out = fibonacci_entry_bands_js(
openValues,
highValues,
lowValues,
closeValues,
"hlc3",
21,
14,
true,
"low",
);
console.log(out.basis, out.upper_1618, out.long_entry, out.rejection_short);
const batch = fibonacci_entry_bands_batch_js(openValues, highValues, lowValues, closeValues, {
length_range: [21, 34, 13],
atr_length_range: [14, 21, 7],
source: "hlc3",
use_atr: true,
tp_aggressiveness: "low",
});
console.log(batch.basis, batch.long_entry, batch.lengths, batch.atr_lengths, batch.rows, batch.cols, batch.combos); CUDA Bindings (Rust)
Additional details for the CUDA bindings can be found inside the VectorTA repository.
Performance Analysis
Across sizes, Rust CPU runs about 1.14× faster than Tulip C in this benchmark.
AMD Ryzen 9 9950X (CPU) | NVIDIA RTX 4090 (GPU)