Trend Trigger Factor
length = 15 Overview
Trend Trigger Factor is a compact high-low oscillator that compares recent structure across a single rolling window. It is simpler than a full multi-line trend study, but that simplicity is useful when you want one series that reacts to directional expansion without also carrying several smoothing, signal, or confirmation layers.
In VectorTA the indicator accepts high and low slices directly or candle data through the standard input object, supports a streaming update path for live bars, and exposes a batch length sweep for parameter studies. It is a good fit when you want one trend-pressure oscillator that can be tuned with a single length control.
Defaults: `length = 15`.
Implementation Examples
Run the trigger factor on direct high-low slices or on candle data with the default length.
use vector_ta::indicators::trend_trigger_factor::{
trend_trigger_factor,
TrendTriggerFactorInput,
TrendTriggerFactorParams,
};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};
let direct = trend_trigger_factor(&TrendTriggerFactorInput::from_slices(
&high,
&low,
TrendTriggerFactorParams { length: Some(15) },
))?;
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let from_candles = trend_trigger_factor(
&TrendTriggerFactorInput::with_default_candles(&candles),
)?;
println!("latest factor = {:?}", direct.values.last());
println!("candle factor = {:?}", from_candles.values.last()); API Reference
Input Methods ▼
TrendTriggerFactorInput::from_candles(&Candles, TrendTriggerFactorParams)
-> TrendTriggerFactorInput
TrendTriggerFactorInput::from_slices(&[f64], &[f64], TrendTriggerFactorParams)
-> TrendTriggerFactorInput
TrendTriggerFactorInput::with_default_candles(&Candles)
-> TrendTriggerFactorInput Parameters Structure ▼
pub struct TrendTriggerFactorParams {
pub length: Option<usize>, // default 15
} Output Structure ▼
pub struct TrendTriggerFactorOutput {
pub values: Vec<f64>,
} Validation, Warmup & NaNs ▼
- The high and low slices must both be non-empty, the same length, and contain at least one valid finite pair.
- The resolved
lengthmust be greater than zero and no larger than the available data. - The indicator rejects cases where the remaining valid data after the first usable bar is shorter than the requested length.
- Batch mode validates the length sweep and rejects invalid kernels for batch execution.
Builder, Streaming & Batch APIs ▼
TrendTriggerFactorBuilder::new()
.length(usize)
.kernel(Kernel)
.apply(&Candles)
.apply_slices(&[f64], &[f64])
.into_stream()
TrendTriggerFactorStream::try_new(params)
stream.update(high, low) -> f64
TrendTriggerFactorBatchBuilder::new()
.length_range((start, end, step))
.apply_slices(&[f64], &[f64]) Python Bindings
Python exposes a direct function returning the factor series, a small stream class for live high-low updates, and a batch helper that returns the factor matrix with the resolved length axis.
from vector_ta import (
trend_trigger_factor,
trend_trigger_factor_batch,
TrendTriggerFactorStream,
)
values = trend_trigger_factor(high, low, length=15)
stream = TrendTriggerFactorStream(length=15)
point = stream.update(high[-1], low[-1])
batch = trend_trigger_factor_batch(
high,
low,
length_range=(10, 30, 5),
) JavaScript/WASM Bindings
The WASM surface exposes direct, batch, allocation, and into-buffer helpers. The direct API returns the factor values as a plain array, while the batch and into-buffer helpers cover heavier parameter-sweep workflows.
import init, {
trend_trigger_factor_js,
trend_trigger_factor_batch_js,
trend_trigger_factor_alloc,
trend_trigger_factor_free,
trend_trigger_factor_into,
trend_trigger_factor_batch_into,
} from "vector-ta-wasm";
await init();
const single = trend_trigger_factor_js(high, low, 15);
const batch = trend_trigger_factor_batch_js(high, low, {
length_range: [10, 30, 5],
});
console.log(single.at(-1), 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)