Weighted Close Price (WCLPRICE)
Overview
Weighted Close Price calculates a simplified representation of daily price action by averaging the high, low, and closing prices while giving double weight to the close through the formula (High + Low + 2×Close) / 4, recognizing that where a market settles often matters more than its extremes. This price transformation evolved as a fundamental tool in technical analysis to address the limitations of simple line charts that only display closing prices, providing a smoother series that captures the full trading range while emphasizing the most significant price point. Unlike Typical Price which weights all three values equally, Weighted Close acknowledges that the closing price represents the final consensus of all market participants after a full session of price discovery. The indicator proves particularly useful when applying moving averages or other technical studies that require a single price input, as it reduces the impact of irregular spikes in high and low prices that might distort analysis. Traders often substitute Weighted Close for raw closing prices in their calculations to filter out intraday volatility while maintaining the essential price direction information. By combining the simplicity of a single line with the comprehensive scope of bar chart data, WCLPRICE creates a balanced view that smooths price action without losing critical market information about where prices actually traded throughout the session.
Implementation Examples
Compute WCLPRICE from slices or Candles:
use vectorta::indicators::wclprice::{wclprice, WclpriceInput, WclpriceParams};
use vectorta::utilities::data_loader::{Candles, read_candles_from_csv};
// Using with OHLC slices
let high = vec![100.0, 102.0, 101.0];
let low = vec![ 98.0, 100.0, 99.5];
let close = vec![ 99.0, 101.0, 100.5];
let input = WclpriceInput::from_slices(&high, &low, &close);
let out = wclprice(&input)?;
// Using with Candles data structure (selects high/low/close)
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let input = WclpriceInput::with_default_candles(&candles);
let out = wclprice(&input)?;
// Access values
for v in out.values {
println!("WCLPRICE: {}", v);
} API Reference
Input Methods ▼
// From OHLC slices
WclpriceInput::from_slices(&[f64], &[f64], &[f64]) -> WclpriceInput
// From candles (uses high/low/close fields)
WclpriceInput::from_candles(&Candles) -> WclpriceInput
// With defaults (alias for from_candles)
WclpriceInput::with_default_candles(&Candles) -> WclpriceInput Parameters Structure ▼
pub struct WclpriceParams; // Default: Self Output Structure ▼
pub struct WclpriceOutput {
pub values: Vec<f64>,
} Validation, Warmup & NaNs ▼
high/low/closemust be non-empty; otherwiseWclpriceError::EmptyData.- Computes to the minimum common length of
high/low/close. Forwclprice_into_slice, mismatched output length →WclpriceError::InvalidOutputLen. - Leading indices before the first triple of finite inputs are
NaN; if none found →WclpriceError::AllValuesNaN. - Candles: missing
"high","low", or"close"field →WclpriceError::MissingField. - Batch APIs require a batch kernel; otherwise
WclpriceError::InvalidBatchKernel. - Streaming:
WclpriceStream::update(h,l,c)returnsNoneif any input isNaN, else the weighted value.
Error Handling ▼
use vectorta::indicators::wclprice::{wclprice, WclpriceInput, WclpriceError};
let input = WclpriceInput::from_slices(&high, &low, &close);
match wclprice(&input) {
Ok(out) => process(out.values),
Err(WclpriceError::EmptyData) => eprintln!("wclprice: empty input"),
Err(WclpriceError::AllValuesNaN) => eprintln!("wclprice: all values are NaN"),
Err(WclpriceError::InvalidOutputLen { out, min_len }) =>
eprintln!("wclprice: output len {} must equal {}", out, min_len),
Err(WclpriceError::MissingField { field }) =>
eprintln!("wclprice: missing candle field '{}'", field),
Err(WclpriceError::InvalidBatchKernel(k)) =>
eprintln!("wclprice: invalid batch kernel: {:?}", k),
} Python Bindings
Basic Usage ▼
Compute WCLPRICE using NumPy arrays of float64:
import numpy as np
from vectorta import wclprice
high = np.array([100.0, 102.0, 101.0], dtype=np.float64)
low = np.array([ 98.0, 100.0, 99.5], dtype=np.float64)
close= np.array([ 99.0, 101.0, 100.5], dtype=np.float64)
# Auto kernel (default) or specify: 'scalar' | 'avx2' | 'avx512'
values = wclprice(high, low, close, kernel='auto')
print(values) Streaming Real-time Updates ▼
Update per-tick with OHLC triples:
from vectorta import WclpriceStream
stream = WclpriceStream()
for (h, l, c) in ohlc_feed:
v = stream.update(h, l, c)
if v is not None:
use(v) Batch Processing ▼
WCLPRICE has no parameters; batch returns a single row:
import numpy as np
from vectorta import wclprice_batch
out = wclprice_batch(high, low, close, kernel='auto')
print(out['values'].shape) # (1, len(high))
# Access the only row
row0 = out['values'][0]
print(row0[:5]) CUDA Acceleration ▼
Available when built with Python+CUDA features:
import numpy as np
from vectorta import wclprice_cuda_dev
high_f32 = np.asarray(high, dtype=np.float32)
low_f32 = np.asarray(low, dtype=np.float32)
close_f32= np.asarray(close,dtype=np.float32)
dev_arr = wclprice_cuda_dev(high_f32, low_f32, close_f32, device_id=0)
# dev_arr is a device-backed array wrapper (f32) JavaScript/WASM Bindings
Basic Usage ▼
Compute WCLPRICE in JS/TS:
import { wclprice_js } from 'vectorta-wasm';
const high = new Float64Array([100.0, 102.0, 101.0]);
const low = new Float64Array([ 98.0, 100.0, 99.5]);
const close = new Float64Array([ 99.0, 101.0, 100.5]);
const values = wclprice_js(high, low, close);
console.log(values); Memory-Efficient Operations ▼
Use zero-copy operations for large datasets:
import { wclprice_alloc, wclprice_free, wclprice_into, memory } from 'vectorta-wasm';
const len = high.length; // min length of arrays
const hPtr = wclprice_alloc(len);
const lPtr = wclprice_alloc(len);
const cPtr = wclprice_alloc(len);
const outPtr = wclprice_alloc(len);
new Float64Array(memory.buffer, hPtr, len).set(high);
new Float64Array(memory.buffer, lPtr, len).set(low);
new Float64Array(memory.buffer, cPtr, len).set(close);
// Compute directly into pre-allocated output
wclprice_into(hPtr, lPtr, cPtr, outPtr, len);
const out = new Float64Array(memory.buffer, outPtr, len).slice();
// Free allocations
wclprice_free(hPtr, len);
wclprice_free(lPtr, len);
wclprice_free(cPtr, len);
wclprice_free(outPtr, len);
console.log(out); Batch Processing ▼
Unified batch interface (no parameters for WCLPRICE):
import { wclprice_batch } from 'vectorta-wasm';
const cfg = {}; // reserved for future
const result = wclprice_batch(high, low, close, cfg);
// result: { values: Float64Array, combos: WclpriceParams[], rows: number, cols: number }
console.log(result.rows, result.cols);
console.log(result.values); Performance Analysis
AMD Ryzen 9 9950X (CPU) | NVIDIA RTX 4090 (GPU) | Benchmarks: 2026-01-05