Trend Continuation Factor
length = 35 Overview
Trend Continuation Factor measures how strongly price is continuing upward versus downward and publishes those two pressures separately as `plus_tcf` and `minus_tcf`. That makes it easier to compare the balance between bullish and bearish continuation rather than collapsing both sides into a single signed oscillator.
In VectorTA the indicator works on a single source slice or on candle data with the default close field, supports a streaming state machine for live updates, and exposes batch sweeps across the length control. It is a simple interface, but the paired output is useful when you want to study whether one side of the market is extending while the other is fading rather than merely crossing zero.
Defaults: `length = 35`.
Implementation Examples
Run the paired continuation outputs on a direct source slice or on candle closes.
use vector_ta::indicators::trend_continuation_factor::{
trend_continuation_factor,
TrendContinuationFactorInput,
TrendContinuationFactorParams,
};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};
let direct = trend_continuation_factor(&TrendContinuationFactorInput::from_slice(
&close,
TrendContinuationFactorParams { length: Some(35) },
))?;
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let from_candles = trend_continuation_factor(
&TrendContinuationFactorInput::with_default_candles(&candles),
)?;
println!("plus = {:?}", direct.plus_tcf.last());
println!("minus = {:?}", direct.minus_tcf.last());
println!("candle plus = {:?}", from_candles.plus_tcf.last());API Reference
Input Methods▼
TrendContinuationFactorInput::from_candles(&Candles, "close", TrendContinuationFactorParams)
-> TrendContinuationFactorInput
TrendContinuationFactorInput::from_slice(&[f64], TrendContinuationFactorParams)
-> TrendContinuationFactorInput
TrendContinuationFactorInput::with_default_candles(&Candles)
-> TrendContinuationFactorInputParameters Structure▼
pub struct TrendContinuationFactorParams {
pub length: Option<usize>, // default 35
}Output Structure▼
pub struct TrendContinuationFactorOutput {
pub plus_tcf: Vec<f64>,
pub minus_tcf: Vec<f64>,
}Validation, Warmup & NaNs▼
- The source slice must not be empty or entirely NaN, and the resolved
lengthmust fit the available data. - The stream returns
Noneuntil enough valid bars accumulate to seed both continuation-pressure series. - Output buffers must align with the source length or the indicator returns the documented output-length mismatch error.
- Batch mode validates the length axis and rejects invalid sweep ranges.
Builder, Streaming & Batch APIs▼
TrendContinuationFactorBuilder::new()
.length(usize)
.kernel(Kernel)
.apply(&Candles)
.apply_slice(&[f64])
.into_stream()
TrendContinuationFactorStream::try_new(params)
stream.update(value) -> Option<(f64, f64)>
TrendContinuationFactorBatchBuilder::new()
.length_range(start, end, step)
.apply_slice(&[f64])Python Bindings
Python exposes a direct function, a stream class, and a batch helper that returns paired matrices for the positive and negative continuation factors.
from vector_ta import (
trend_continuation_factor,
trend_continuation_factor_batch,
TrendContinuationFactorStream,
)
plus_tcf, minus_tcf = trend_continuation_factor(close, length=35)
stream = TrendContinuationFactorStream(length=35)
point = stream.update(close[-1])
batch = trend_continuation_factor_batch(close, length_range=(20, 50, 5))JavaScript/WASM Bindings
The WASM layer exposes direct, batch, and into-buffer entry points for callers that want either the simple object-returning path or manual memory control.
import init, {
trend_continuation_factor_js,
trend_continuation_factor_batch_js,
trend_continuation_factor_alloc,
trend_continuation_factor_free,
trend_continuation_factor_into,
trend_continuation_factor_into_host,
trend_continuation_factor_batch_into,
} from "vector-ta-wasm";
await init();
const single = trend_continuation_factor_js(close, 35);
console.log(single.plus_tcf, single.minus_tcf);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)