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 vectorta import MwdxStream

stream = MwdxStream(factor=0.2)
val = stream.update(100.0)
Batch
import numpy as np
from vectorta 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'])

Implementation Examples

Compute MWDX from slices or candles:

use vectorta::indicators::moving_averages::mwdx::{mwdx, MwdxInput, MwdxParams};
use vectorta::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 vectorta::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);

Performance Analysis

Comparison:
View:
Loading chart...

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

Related Indicators