Trend Flow Trail
alpha_length = 33 | alpha_multiplier = 3.3 | mfi_length = 14 Overview
Trend Flow Trail is a multi-output trend study built around an adaptive alpha trail and a money-flow style confirmation layer. Instead of returning one line, it exposes the active trail, separated bullish and bearish trail states, a directional regime series, upper and lower trigger-price bands, and event flags for switches, crossovers, and momentum extremes. That makes it useful when you want both a plotted trail and the state machine that explains why the trail is changing.
In VectorTA the indicator works on full OHLCV input, supports direct slice execution, streaming updates, and multi-axis batch sweeps across the alpha-trail and money-flow controls. The result is best treated as a compact trend dashboard: one call returns the trail itself, directional state, trigger-price bands, and boolean-style event series that can be used for alerts or downstream filtering.
Defaults: `alpha_length = 33`, `alpha_multiplier = 3.3`, and `mfi_length = 14`.
Implementation Examples
Run Trend Flow Trail on direct OHLCV slices or on candle data with the default parameter set.
use vector_ta::indicators::trend_flow_trail::{
trend_flow_trail,
TrendFlowTrailInput,
TrendFlowTrailParams,
};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};
let direct = trend_flow_trail(&TrendFlowTrailInput::from_slices(
&open,
&high,
&low,
&close,
&volume,
TrendFlowTrailParams {
alpha_length: Some(33),
alpha_multiplier: Some(3.3),
mfi_length: Some(14),
},
))?;
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let from_candles = trend_flow_trail(&TrendFlowTrailInput::with_default_candles(&candles))?;
println!("latest alpha trail = {:?}", direct.alpha_trail.last());
println!("latest direction = {:?}", direct.alpha_dir.last());
println!("latest mfi = {:?}", from_candles.mfi.last()); API Reference
Input Methods ▼
TrendFlowTrailInput::from_candles(&Candles, TrendFlowTrailParams)
-> TrendFlowTrailInput
TrendFlowTrailInput::from_slices(&[f64], &[f64], &[f64], &[f64], &[f64], TrendFlowTrailParams)
-> TrendFlowTrailInput
TrendFlowTrailInput::with_default_candles(&Candles)
-> TrendFlowTrailInput Parameters Structure ▼
pub struct TrendFlowTrailParams {
pub alpha_length: Option<usize>, // default 33
pub alpha_multiplier: Option<f64>, // default 3.3
pub mfi_length: Option<usize>, // default 14
} Output Structure ▼
pub struct TrendFlowTrailOutput {
pub alpha_trail: Vec<f64>,
pub alpha_trail_bullish: Vec<f64>,
pub alpha_trail_bearish: Vec<f64>,
pub alpha_dir: Vec<f64>,
pub mfi: Vec<f64>,
pub tp_upper: Vec<f64>,
pub tp_lower: Vec<f64>,
pub alpha_trail_bullish_switch: Vec<f64>,
pub alpha_trail_bearish_switch: Vec<f64>,
pub mfi_overbought: Vec<f64>,
pub mfi_oversold: Vec<f64>,
pub mfi_cross_up_mid: Vec<f64>,
pub mfi_cross_down_mid: Vec<f64>,
pub price_cross_alpha_trail_up: Vec<f64>,
pub price_cross_alpha_trail_down: Vec<f64>,
pub mfi_above_90: Vec<f64>,
pub mfi_below_10: Vec<f64>,
} Validation, Warmup & NaNs ▼
- OHLCV slices must all have the same non-zero length and include at least one fully finite bar.
- The resolved
alpha_length,alpha_multiplier, andmfi_lengthmust each pass the module validation checks. - The indicator rejects datasets that do not have enough valid data after the first usable OHLCV bar.
- Batch mode validates all three parameter axes and rejects non-batch kernels.
Builder, Streaming & Batch APIs ▼
TrendFlowTrailBuilder::new()
.alpha_length(usize)
.alpha_multiplier(f64)
.mfi_length(usize)
.kernel(Kernel)
.apply(&Candles)
.apply_slices(&[f64], &[f64], &[f64], &[f64], &[f64])
.into_stream()
TrendFlowTrailStream::try_new(params)
stream.update(open, high, low, close, volume) -> Option<(...)>
TrendFlowTrailBatchBuilder::new()
.alpha_length(start, end, step)
.alpha_multiplier(start, end, step)
.mfi_length(start, end, step)
.apply_slices(&[f64], &[f64], &[f64], &[f64], &[f64]) Python Bindings
Python exposes a dictionary-returning function, a stream class that emits the full 17-field row, and a batch helper that reshapes every output field into a row-by-column grid for parameter studies.
from vector_ta import (
trend_flow_trail,
trend_flow_trail_batch,
TrendFlowTrailStream,
)
single = trend_flow_trail(
open,
high,
low,
close,
volume,
alpha_length=33,
alpha_multiplier=3.3,
mfi_length=14,
)
print(single["alpha_trail"][-1], single["mfi"][-1])
stream = TrendFlowTrailStream(alpha_length=33, alpha_multiplier=3.3, mfi_length=14)
row = stream.update(open[-1], high[-1], low[-1], close[-1], volume[-1])
batch = trend_flow_trail_batch(
open,
high,
low,
close,
volume,
alpha_length_range=(21, 55, 4),
alpha_multiplier_range=(2.0, 4.0, 0.5),
mfi_length_range=(10, 18, 2),
) JavaScript/WASM Bindings
The WASM layer exposes object-returning direct and batch calls plus manual allocation helpers and into-buffer entry points for callers that want tighter memory control around OHLCV arrays.
import init, {
trend_flow_trail_js,
trend_flow_trail_alloc,
trend_flow_trail_free,
trend_flow_trail_into,
trend_flow_trail_batch,
} from "vector-ta-wasm";
await init();
const single = trend_flow_trail_js(
open,
high,
low,
close,
volume,
33,
3.3,
14,
);
console.log(single.alpha_trail, single.mfi);
const batch = trend_flow_trail_batch(open, high, low, close, volume, {
alpha_length_range: [21, 55, 4],
alpha_multiplier_range: [2.0, 4.0, 0.5],
mfi_length_range: [10, 18, 2],
});
console.log(batch.rows, batch.cols); 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)