2001issue C091-6
Encoding candle structure as a numeric filter
One CandleCode construction turns each bar into a single score by weighting body color, body size, shadows, and gap. After double smoothing, that score can be read with a threshold crossing or with Bollinger band crossings.
- CandleCode assigns separate integer weights to body color, body size, upper shadow, lower shadow, and gap, then adds those signed components into one bar score.
- A double-smoothed CandleCode series can define a long or short through a threshold crossing at replaceable levels, or through a band crossing on Bollinger envelopes built from the same series.
- The encoded series can be plotted raw, single-smoothed, double-smoothed, or as a CandleCode oscillator that uses a zero-line cross as a scan condition.
- The MESA adaptive moving average can be plotted with a slower following adaptive moving average as a two-line overlay on price.
A weighted score for each bar
One CandleCode construction assigns separate integer weights to body color, body size, upper shadow, lower shadow, and gap, then adds those signed components into a single bar score.
The body-color weight is added for an up candle, subtracted for a down candle, and omitted when open and close are equal. The body-size component scales with how large the candle body is, from a large down body to a large up body. Each shadow component is the bullish increment from an upper shadow or the bearish decrement from a lower shadow, and both are zero when that shadow is absent. The gap component is the signed increment for the distance between the current open and the prior close.
Example weights
In the worked weighting example, body color and body size each use 32, each shadow uses 16, and the gap uses 8. A white body adds 32, a black body subtracts 32, and an unchanged body contributes nothing from color.
Under those same example weights the body-size component ranges from -32 to +32, each shadow component ranges from 0 to 16 in absolute value, and the gap component ranges from -8 to +8.
Threshold crossing after double smoothing
A turning-point rule can be built by double-smoothing CandleCode with successive averages of 21 and 3 bars. The double-smoothed CandleCode series can then be read more slowly than the raw score.
A long is taken when that series crosses above 50, and a short is taken when it crosses below 70. Those levels are replaceable examples of a threshold crossing.
Band crossing on the same series
A second rule keeps the same 21-then-3 double-smoothed CandleCode series but replaces the fixed levels with 20-period, 2-deviation Bollinger envelopes. It goes long on a cross above the lower band and short on a cross below the upper band.
That band crossing uses envelopes built from the encoded series itself rather than from a separate price line.
Ways to plot the encoded series
The encoded series can be plotted raw, single-smoothed, double-smoothed, or as a CandleCode oscillator equal to the difference between the single-smoothed and double-smoothed lines.
Readings from a small sample
On a small sample of three-minute bars, slope changes of the double-smoothed line in extreme territory and oscillator crosses of the zero line were described as the most useful leading readings.
A scan can treat a CandleCode oscillator move from below zero to at or above zero as a buy condition and the opposite cross as a sell condition.
CandleCode band-crossing net return versus buy-and-hold

The test dropped short trades after they reduced stock results, set Bollinger deviations to 2.0, started at $50,000 with a $5,000 base size, and used 12 randomly chosen Nasdaq-100 names.
Adaptive averages as a price overlay
The MESA adaptive moving average can be implemented as an external library routine and plotted with a slower following adaptive moving average as a two-line overlay on price.
All readings on this track · 24 readings
- 1991Building variable-length moving averages from partitioned price changes
- 1991Variable-length moving average from change dispersion
- 1992Constructing volatility-adaptive exponential smoothing
- 1995Constructing an adaptive moving average with an efficiency ratio and filter
- 1995Two-gate breakout confirmation with adaptive averages
- 1995Building momentum-scaled adaptive moving averages
- 1995Adaptive length as a construction choice inside exponential smoothing
- 1998Testing price-channel breakouts with a lag-aware adaptive average
- 1998Constructing filters by nesting offsets and variable weights
- 1998Constructing an efficiency ratio adaptive average and entry filter
- 2001Encoding candle structure as a numeric filter
- 2001Adaptive averages driven by cycle-phase speed
- 2005Constructing an adaptive moving average from a fractal-dimension weight
- 2005Range-dimension adaptive exponential filter
- 2010Constructing simple, exponential, and adaptive averages
- 2010How a price-hugging smoother is assembled from ordinary averages
- 2013Evaluating an adaptive moving average against a same-window moving average
- 2016Three-layer confirmation: adaptive average, stochastic relative strength index, and stop-and-reverse
- 2017One-alpha reverse-path exponential smoothing
- 2018Pair two adaptive averages to filter swing turns
- 2018Two Adaptive moving averages as a confirmation pair
- 2018Constructing an adaptive filter for adoption-cycle reversals
- 2018Constructing a deviation-scaled adaptive moving average
- 2020Walk-forward and adaptive averages as two tests of the same trend