Price Density Market Noise
length = 14 | eval_period = 200 Overview
Price Density Market Noise measures how much cumulative movement is required to travel across a rolling price window. It sums true range over the selected window, divides that by the window's net high-low span, and then keeps a longer evaluation history to rank the current density reading as a percentile-style market noise score.
In practice this gives you two related outputs: the raw density value and a normalized percent reading that shows whether the current market structure is quiet, directional, and efficient or noisy, overlapping, and rotational relative to recent history. The streaming path resets on invalid bars so both the density and ranking state stay internally consistent.
Defaults: `length = 14` and `eval_period = 200`.
Implementation Examples
Use the candle path for the default OHLC inputs or pass explicit high, low, and close slices.
use vector_ta::indicators::price_density_market_noise::{
price_density_market_noise,
PriceDensityMarketNoiseInput,
PriceDensityMarketNoiseParams,
};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};
let direct = price_density_market_noise(&PriceDensityMarketNoiseInput::from_slices(
&high,
&low,
&close,
PriceDensityMarketNoiseParams {
length: Some(14),
eval_period: Some(200),
},
))?;
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let from_candles = price_density_market_noise(&PriceDensityMarketNoiseInput::with_default_candles(&candles))?;
println!("density = {:?}", direct.price_density.last());
println!("percent = {:?}", from_candles.price_density_percent.last());API Reference
Input Methods▼
PriceDensityMarketNoiseInput::from_candles(&Candles, PriceDensityMarketNoiseParams)
-> PriceDensityMarketNoiseInput
PriceDensityMarketNoiseInput::from_slices(&[f64], &[f64], &[f64], PriceDensityMarketNoiseParams)
-> PriceDensityMarketNoiseInput
PriceDensityMarketNoiseInput::with_default_candles(&Candles)
-> PriceDensityMarketNoiseInputParameters Structure▼
pub struct PriceDensityMarketNoiseParams {
pub length: Option<usize>, // default 14
pub eval_period: Option<usize>, // default 200
}Output Structure▼
pub struct PriceDensityMarketNoiseOutput {
pub price_density: Vec<f64>,
pub price_density_percent: Vec<f64>,
}Validation, Warmup & Percent Rank▼
- High, low, and close arrays must have identical lengths and the input must not be empty.
lengthandeval_periodmust both be greater than0.- A valid bar requires finite high, low, and close values; invalid bars reset the streaming state.
- The raw density series warms up through
first_valid + length - 1. - The percent series warms up through
first_valid + length + eval_period - 2. - Batch mode validates both numeric sweep axes and rejects non-batch kernels.
Builder, Streaming & Batch APIs▼
PriceDensityMarketNoiseBuilder::new()
.length(usize)
.eval_period(usize)
.kernel(Kernel)
.apply(&Candles)
.apply_slices(&[f64], &[f64], &[f64])
.into_stream()
PriceDensityMarketNoiseStream::try_new(params)
stream.update(high, low, close) -> Option<(f64, f64)>
PriceDensityMarketNoiseBatchBuilder::new()
.length_range(start, end, step)
.eval_period_range(start, end, step)
.length_static(usize)
.eval_period_static(usize)
.kernel(Kernel)
.apply_slices(&[f64], &[f64], &[f64])
.apply_candles(&Candles)Python Bindings
Python exposes a scalar function returning two NumPy arrays, a stream class returning a two-value tuple, and a batch helper returning density and percent matrices plus the resolved parameter axes.
from vector_ta import (
price_density_market_noise,
price_density_market_noise_batch,
PriceDensityMarketNoiseStream,
)
price_density, price_density_percent = price_density_market_noise(
high,
low,
close,
length=14,
eval_period=200,
)
stream = PriceDensityMarketNoiseStream(length=14, eval_period=200)
point = stream.update(high[-1], low[-1], close[-1])
batch = price_density_market_noise_batch(
high,
low,
close,
length_range=(10, 20, 5),
eval_period_range=(100, 200, 100),
)
print(batch["price_density"].shape)
print(batch["eval_periods"])JavaScript/WASM Bindings
The WASM layer exposes a high-level object-returning call, a batch helper for the two output matrices, and low-level allocation and into-buffer helpers that write both series into caller-managed memory.
import init, {
price_density_market_noise_js,
price_density_market_noise_batch_js,
price_density_market_noise_alloc,
price_density_market_noise_free,
price_density_market_noise_into,
price_density_market_noise_into_host,
price_density_market_noise_batch_into,
} from "vector-ta-wasm";
await init();
const single = price_density_market_noise_js(high, low, close, 14, 200);
console.log(single.price_density, single.price_density_percent);
const batch = price_density_market_noise_batch_js(high, low, close, {
length_range: [10, 20, 5],
eval_period_range: [100, 200, 100],
});
const ptr = price_density_market_noise_alloc(close.length);
price_density_market_noise_free(ptr, close.length);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)