Midway Weighted Exponential (MWDX)

Parameters: factor = 0.2 (0.01–0.99)

Overview

The Midway Weighted Exponential indicator applies exponential smoothing to price data using a configurable alpha factor that determines how much weight recent prices receive versus historical values, creating a responsive yet smooth trend line. MWDX calculates each new value by blending the current input with the previous smoothed output, where a higher alpha factor makes the indicator more responsive to recent changes while lower values produce smoother, more stable results. This exponential weighting scheme ensures recent data has greater influence than older data, but unlike simple moving averages, the influence of past values never completely disappears, creating a cumulative memory effect. Traders utilize MWDX for trend identification and noise reduction, as it responds faster to genuine price movements than simple averages while filtering out minor fluctuations. The indicator particularly excels in trending markets where its adaptive nature allows it to stay close to price during strong moves yet smooth out consolidation periods effectively.

Python Bindings

Streaming
from vector_ta import MwdxStream

stream = MwdxStream(factor=0.2)
val = stream.update(100.0)
Batch
import numpy as np
from vector_ta import mwdx_batch

arr = np.array([100.0, 102.0, 101.5])
res = mwdx_batch(arr, factor_range=(0.1, 0.3, 0.1), kernel="auto")
print(res['values'].shape, res['factors'])
CUDA Acceleration

CUDA helpers are available when the Python package is built with CUDA support. Inputs must be float32; outputs are device arrays (DLPack / __cuda_array_interface__ compatible).

import numpy as np
    from vector_ta import mwdx_cuda_batch_dev, mwdx_cuda_many_series_one_param_dev

    # One series (float32)
    data_f32 = np.asarray(load_data(), dtype=np.float32)

    dev = mwdx_cuda_batch_dev(
    data_f32=data_f32,
    factor_range=(0.5, 2.0, 0.5),
    device_id=0,
    )

    # Many series (time-major)
    data_tm_f32 = np.asarray(load_data_time_major_matrix(), dtype=np.float32)

    dev_tm = mwdx_cuda_many_series_one_param_dev(
    data_tm_f32=data_tm_f32,
    factor=1.0,
    device_id=0,
    )

Implementation Examples

Compute MWDX from slices or candles:

use vector_ta::indicators::moving_averages::mwdx::{mwdx, MwdxInput, MwdxParams};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};

let prices = vec![100.0, 102.0, 101.5];
let input = MwdxInput::from_slice(&prices, MwdxParams { factor: Some(0.2) });
let out = mwdx(&input)?;

let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let input = MwdxInput::with_default_candles(&candles);
let out = mwdx(&input)?;

API Reference

Input Methods
MwdxInput::from_slice(&[f64], MwdxParams)
MwdxInput::from_candles(&Candles, &str, MwdxParams)
MwdxInput::with_default_candles(&Candles)
Parameters Structure
pub struct MwdxParams {
    pub factor: Option<f64>, // Default: 0.2; must be > 0 and finite
}
Output Structure
pub struct MwdxOutput { pub values: Vec<f64> }
Validation, Warmup & NaNs
  • factor > 0, finite; else MwdxError::InvalidFactor.
  • Guard against invalid denominator; else MwdxError::InvalidDenominator.
  • Empty input: MwdxError::EmptyData. Into-slice length mismatch: MwdxError::InvalidLength.
  • Warmup: leading NaNs preserved; first valid output equals first finite input.
Error Handling
use vector_ta::indicators::moving_averages::mwdx::{mwdx, MwdxError};
match mwdx(&input) {
  Ok(o) => process(o.values),
  Err(MwdxError::EmptyData) => eprintln!("no input"),
  Err(MwdxError::InvalidFactor { .. }) => eprintln!("bad factor"),
  Err(MwdxError::InvalidDenominator { .. }) => eprintln!("bad denom"),
  Err(MwdxError::InvalidLength { expected, actual }) => eprintln!("len {} != {}", actual, expected),
}

JavaScript/WASM Bindings

Basic Usage
import { mwdx_js } from 'vectorta-wasm';
const prices = new Float64Array([100, 102, 101]);
const out = mwdx_js(prices, 0.2);

CUDA Bindings (Rust)

use vector_ta::cuda::CudaMwdx;
use vector_ta::indicators::moving_averages::mwdx::MwdxBatchRange;

let cuda = CudaMwdx::new(0)?;

let data_f32: [f32] = /* ... */;
let sweep = MwdxBatchRange::default();

let out = cuda.mwdx_batch_dev(&data_f32, &sweep)?;
let _ = out;

Performance Analysis

Comparison:
View:
Loading chart...

AMD Ryzen 9 9950X (CPU) | NVIDIA RTX 4090 (GPU) | Benchmarks: 2026-02-28

Related Indicators