Class WmaRTIndicator
java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.core.AbstractWindowSeriesRTIndicator
com.wualabs.qtsurfer.engine.indicators.averages.pro.WmaRTIndicator
- All Implemented Interfaces:
Resettable, RTIndicator
Weighted Moving Average (WMA) with O(1) incremental updates.
Instead of recomputing the full weighted sum on every tick (O(window)),
this implementation maintains running weightedSum and plainSum
accumulators that are adjusted incrementally when the window rolls.
Algebraic trick when the window is full and a new value enters:
weightedSum -= plainSum // shift all weights down by 1 plainSum -= evicted // remove evicted value plainSum += newValue // add new value weightedSum += periods × newValue // new value enters with max weight
Pro-tier twin of the free WmaRTIndicator
(the simple O(window) reference): both produce identical results, this one in O(1) per tick.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class AbstractWindowSeriesRTIndicator
getPeriods, isReady, reset, window, windowSizeMethods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, setValue, toString, toString, withDisplayHint, withMeta
-
Constructor Details
-
WmaRTIndicator
public WmaRTIndicator(int periods)
-
-
Method Details
-
onEvict
protected void onEvict(double evicted) Description copied from class:AbstractWindowSeriesRTIndicatorCalled when the window evicts the oldest value. Override to update accumulators.- Overrides:
onEvictin classAbstractWindowSeriesRTIndicator
-
onReset
protected void onReset()Description copied from class:AbstractWindowSeriesRTIndicatorCalled after window is cleared. Override to zero accumulators.- Overrides:
onResetin classAbstractWindowSeriesRTIndicator
-
update
public double update(double newValue) - Specified by:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractRTIndicator
-