These indicators smooth price into a single “band” series. In strategies, they are used in pairs: a signal triggers when second − first changes sign on a closed bar.
Understand moving averages as noise‑reducing filters and how they differ (SMA, EMA, HMA, JMA, etc.).
Interpret length and offset and their impact on lag, smoothness, and signal frequency.
Apply fast vs slow MA cross logic on closed bars with next‑open execution.
Formulas (Plain English)
SMA: Average of the last N closes.
EMA: Weighted average with decay α ≈ 2/(N+1) on the latest close; prior EMA carries (1−α).
RMA: Wilder’s smoothing; EMA‑like with α = 1/N; common in RSI.
WMA: Linear weights across the window (newest gets largest weight).
HMA: Composite of WMAs that reduces lag using √N for the final window.
DEMA/TEMA: Linear combinations of EMA and EMA‑of‑EMA to further reduce lag (more responsive).
You don’t need the algebra to use them effectively; understand which are faster vs smoother and pair accordingly.
Fundamentals
Moving averages (MAs) are smoothing filters applied to price to reveal the underlying direction. Increasing the window length yields a smoother line with more
lag; decreasing the window makes the MA faster and more sensitive to noise. Choice of weighting (simple vs exponential vs hull) further trades responsiveness
against smoothness.
Smoothing vs lag: Higher length → fewer flips, later reaction; lower length → more flips, faster reaction.
Weighting: EMA/HMA/JMA reduce apparent lag at the same length vs SMA; DEMA/TEMA are very responsive but can overshoot.
Warm‑up: Allow a few multiples of the longest length before trusting values in analysis or backtests.
Types (length/offset only)
The following accept length and optional offset. All take close as the primary input unless noted.
Typical length ranges: fast 7–21; medium 34–55; slow 89–200. Pairing a fast and a slow MA amplifies trend crosses while filtering small wiggles.
In general, higher length produces smoother averages with more lag and fewer signals, while lower length tracks price closely but can whipsaw in consolidation. EMA/HMA/JMA tend to reduce apparent lag at a given length compared to SMA.
Fast vs Slow Cross (Illustration)
Specialized MAs
Beyond SMA/EMA, several variants modify weighting to balance smoothness and responsiveness. HMA reduces lag using a double‑smoothing construction. DEMA/TEMA further increase responsiveness but can overshoot. JMA is designed to minimize lag and noise. SSF applies a digital filter approach to suppress aliasing.
HWMA — Holt‑Winter Moving Average
Inputs: close
Factors: na, nb, nc (floats in (0,1)), optional offset
Interpretation: Smooth with low lag. Higher a → faster but more noise.
Use: Good as a mid‑fast line vs slower SMA/EMA.
Parameters & Implementation Notes
length: Higher → smoother with lag; lower → faster with noise. Start with fast 7–21 vs slow 34–55 and tune.
offset: Shifts the output right by N bars; keep 0 to avoid look‑ahead and preserve app parity.
Warm‑up: Stabilize the series before analysis; use ≥ 2× the longest length for EMA/HMA in backtests.
Numerics: Handle NaN/Inf gracefully; compute on closed bars only to avoid repainting.
Signals & Execution
A cross signal occurs when the difference (second − first) changes sign between two consecutive closed bars. If the first (often the fast MA) is above the second (slow MA) on the crossing bar, the direction is SHORT; otherwise LONG. Execute at the opening price of the next bar. Avoid using forming bars for decisions.
Common Pitfalls
Using very small lengths that track noise and cause overtrading.
Choosing fast and slow lengths that are too similar, yielding ambiguous crosses.
Applying non‑zero offset, which breaks parity and may imply look‑ahead.
Evaluating signals on forming bars instead of closed candles.
Recommended presets by interval
1m: first EMA 13–21 vs second SMA 34–55
3m–5m: first HMA 21–34 vs second EMA/SMA 55–89
15m: first EMA 21–34 vs second SMA 89–144
1h: first EMA 34–55 vs second SMA 100–200
These are starting points. Increase the slower baseline for choppy pairs; decrease to trade more frequently.
Offset: Keep 0 for parity. Non‑zero offset is rarely helpful with MAs.
Design Patterns
Fast/Slow Cross: EMA/HMA as fast vs SMA/EMA as slow for trend entries/exits.
Baseline + Signal: Stable baseline (HL2/BBM/VWAP) with a responsive EMA/HMA signal for cleaner direction.
Ribbon: Use multiple MAs (e.g., 8/13/21/34) to visualize compression/expansion and trend strength.
MTF Confirmation: Only take 1m crosses that agree with the 5m baseline slope.
Slope/Separation Filters: Require minimal slope or band separation at cross time to reduce low‑energy trades.
FAQ
Which pair of MAs should I start with? EMA(21) vs SMA(55) on 1m–5m is a practical baseline.
How do I reduce whipsaws? Increase the slow length, use HMA/JMA as fast, or add slope/separation criteria.
How much history do I need? A few multiples of the longest length; more for EMA/HMA to stabilize warm‑up.
Why closed bars only? To avoid repainting and keep results deterministic, matching the app’s logic.