Bug: APO calculation has incorrect EMA alignment
Problem
APO (Absolute Price Oscillator) calculation in trend/apo.go does not properly align Fast EMA and Slow EMA before subtraction.
Root Cause
When computing APO = Fast EMA - Slow EMA, the two EMAs have different periods (default: 14 and 30). The Fast EMA starts producing valid values earlier than the Slow EMA, but they are subtracted without aligning them to the same time point.
Expected Behavior
Fast EMA should skip the first (slowPeriod - fastPeriod) values to align with Slow EMA before subtraction.
Fix
Add one line in trend/apo.go, after line 75:
// Skip the first (slowPeriod - fastPeriod) values to align with slow EMA.
cs[0] = helper.Skip(cs[0], apo.SlowPeriod-apo.FastPeriod)
Reference
Other indicators that correctly implement this pattern:
momentum/ppo.go line 70
trend/macd.go line 59
Bug: APO calculation has incorrect EMA alignment
Problem
APO (Absolute Price Oscillator) calculation in
trend/apo.godoes not properly align Fast EMA and Slow EMA before subtraction.Root Cause
When computing
APO = Fast EMA - Slow EMA, the two EMAs have different periods (default: 14 and 30). The Fast EMA starts producing valid values earlier than the Slow EMA, but they are subtracted without aligning them to the same time point.Expected Behavior
Fast EMA should skip the first
(slowPeriod - fastPeriod)values to align with Slow EMA before subtraction.Fix
Add one line in
trend/apo.go, after line 75:Reference
Other indicators that correctly implement this pattern:
momentum/ppo.goline 70trend/macd.goline 59