What is moving-average curvature? Formula, meaning and a backtest

On this page

Key takeaways

  • Curvature asks whether a moving average is bending upward or downward: whether its rise is speeding up, or its fall slowing down.
  • It reacts earlier than the direction of the average itself, because a turn in a trend shows up first as a change in its pace. The price paid is many false alarms.
  • Dividing by the reading's own typical size puts every fund and every period on one scale, but it never changes whether the reading is above or below zero.
  • On daily bars with the default settings it flips often, so a rule built on it trades many times a year and trading costs matter.
  • The default settings were sized for weekly charts; on daily bars they look at a much shorter stretch of history.

Definition

Moving-average curvature measures whether a moving average's rate of change is speeding up or slowing down: it is the change in the average's percentage change, a discrete second derivative. MarketHeist divides that second difference by its own standard deviation over a long trailing window, so the reading is in units of its typical size and is positive while the average is bending upward.

Also known as: MA curvature, moving average acceleration, second derivative of a moving average, trend acceleration, rate of change of momentum, moving average convexity.

How it works

Think of the price's moving average as a path. Its level says where the trend is, its rate of change says how fast the trend is moving, and the change in that rate says whether the trend is gathering pace or losing it. Curvature is the third of these. A steady rise at a constant pace has no curvature at all; a rise that is speeding up has positive curvature; a rise that is slowing, or a fall that is getting steeper, has negative curvature; and a fall that is easing has positive curvature even while prices are still going down.

MarketHeist builds it in three steps. First, a moving average of the close, simple or exponential, 52 bars by default. Second, the average's percentage change over a lag of 4 bars, its speed. Third, the change in that speed over another 4 bars, its acceleration. The acceleration is then divided by its own sample standard deviation over a trailing window four times as long as the average, which turns it into a z-score-like reading: it says how large today's acceleration is compared with its usual size over that trailing window.

Curvature is like a car's accelerometer: a car still moving forward can already be braking, and the accelerometer shows the braking before the speedometer shows the car slowing down.

That early warning is the appeal and the problem. Each difference amplifies short-term noise, and taking two of them amplifies it twice; the moving average underneath is there to damp that. With a short average and a short lag, the sign of the curvature flips whenever the pace of the trend wobbles, which in a calm market happens constantly. A longer average and lag give a steadier reading that turns later.

Dividing by the standard deviation changes the scale, not the sign. A rule that holds while curvature is above zero takes exactly the same positions with or without the normalization; the normalization matters for thresholds other than zero, and for comparing readings across funds and decades.

Formula

Moving average, its speed and its acceleration
Mt=1w∑k=0w−1Ct−k(or an exponential average of span w)gt=MtMt−L−1,κt=gt−gt−L
Cₜ
the dividend-adjusted close of day t
Mₜ
the moving average of the close
w
the averaging window: 52 bars by default
L
the lag used for both differences: 4 bars by default
gₜ
the average's percentage change over L bars (its speed)
κₜ
the change in that speed over L bars (its acceleration, the curvature)

The exponential version uses the span convention, a weight of 2 / (w + 1) on the newest bar, normalised over the bars seen so far.

Normalized curvature and the rule
zt=κtsd4w(κ)t,st={1zt>θ0otherwise,rt+1rule=st·rt+1
sd₄w(κ)ₜ
sample standard deviation (divides by n − 1) of the curvature over the last 4w bars, day t included
zₜ
normalized curvature, the indicator's signal
θ
the threshold: 0 by default
sₜ
the position decided at the close of day t: 1 = hold, 0 = cash
rₜ₊₁
the fund's total return on the next day

With θ = 0 the rule's positions depend only on the sign of κ, because the standard deviation is positive.

Worked example

SPY daily bars from Oct 2006 to Sep 2026, about 20 years. Rule: hold SPY for the next day while the curvature of its 52-day simple moving average, measured over 4-day steps, closed above zero; otherwise cash; no trading costs.

The curvature was above zero on 49.4% of days: SPY's average spent roughly as much time bending up as bending down, even across a rising market, because a steady rise has no curvature and small changes of pace decide the sign.

That makes a busy rule: 356 round trips, 17.8 a year, holding for 7.0 days on average, with 51.7% of trades closing at a gain. It was invested 49.4% of the time. It grew 2.4% a year, less than the 11.1% of holding SPY throughout. Its worst decline from a peak was -40.4% against -55.2%.

A slower setting trades less. With a 100-day average and 10-day steps the rule made 7.4 round trips a year and grew 4.9% a year, with a worst decline of -37.1%. The exponential average in place of the simple one gave 3.0% a year.

None of these settings was chosen in advance for this window, and the rule has four of them: the window, the type of average, the step length and the threshold. The more combinations a test tries, the more likely the one that looks strongest was fitted to noise; the parameter robustness guide shows how to check.

Data through Sep 2026. Reproduce id e95a1a6bb1d15658 (this guide, its lab setup and the data month).

Interactive lab

SPY's price with the days the rule held it shaded, the normalized curvature underneath with the zero line, and the results of the default rule, the slower setting, the exponential average and buy-and-hold over the same days. Change the window, the lag, the average type, the threshold, the delay, the cost or the fund.

SPY price with the days the base rule held itS&P 500, adjusted daily close, Oct 2006 to Sep 2026, log scale. Shaded: the 356 stretches the base rule held the fund (49% of 5030 days). Also drawn: 52-day simple average.$50$100$200$50020062011201620212026SPY adjusted close52-day simple averageHeld by the base rule
SPY on a log scale. Shaded: the days the base rule held the fund. Oct 2006 to Sep 2026.
Normalized curvature with the base rule's lineNormalized curvature on SPY, Oct 2006 to Sep 2026. The rule compares it with the fixed line 0.-6-5-4-3-2-10123200620112016202120260Normalized curvature
Normalized curvature and the line the base rule compares it with. Oct 2006 to Sep 2026.
Growth of $10,000: the setups against buy and holdS&P 500, Oct 2006 to Sep 2026, log scale. $10,000 grows to $16,176 (base), $26,111 (100-day average, 10-day steps), $17,880 (Exponential 52-day average), $82,292 (buy and hold).$10k$20k$50k20062011201620212026Base rule100-day average, 10-day stepsExponential 52-day averageBuy and hold
Growth of $10,000 on a log scale, same days for every line. Oct 2006 to Sep 2026.
MeasureBase100-day average, 10-day stepsExponential 52-day averageBuy and hold
CAGR2.4%4.9%3.0%11.1%
Volatility (annualized)11.0%10.8%11.7%19.4%
Maximum drawdown-40.4%-37.1%-39.5%-55.2%
Sharpe ratio0.270.500.310.64
Sortino ratio0.370.710.42n/a
Growth of $10,000$16,176$26,111$17,880$82,292
Time in the market49.4%49.6%50.4%100.0%
Round trips356148369n/a
Round trips per year17.87.418.5n/a
Win rate51.7%61.5%49.3%n/a
Average win1.8%3.2%2.0%n/a
Average loss-1.6%-3.2%-1.5%n/a
Payoff ratio1.121.021.28n/a
Average days held7.016.86.9n/a
Expectancy per trade0.2%0.8%0.2%n/a
Profit factor, per day1.081.141.091.13
Profit factor, per trade1.211.631.24n/a
Indicator, last day-0.327-0.549-0.654n/a
Indicator, 10th / 50th / 90th percentile-1.279 / -0.011 / 1.28-1.298 / -0.009 / 1.239-1.225 / 0.012 / 1.191n/a
Days the rule alone is long49.4%49.5%50.4%n/a

S&P 500, Oct 2006 to Sep 2026, 5030 trading days. Every setup is measured over the same days, with the indicator warmed up on earlier ones; cash earns 0. Base: MA Curvature (ma window 52, diff lag 4, ma type SMA); long while the Normalized curvature is above 0; execution delay 1; cost 0 bps one way. 100-day average, 10-day steps: MA Curvature (ma window 100, diff lag 10, ma type SMA); long while the Normalized curvature is above 0; execution delay 1; cost 0 bps one way. Exponential 52-day average: MA Curvature (ma window 52, diff lag 4, ma type EMA); long while the Normalized curvature is above 0; execution delay 1; cost 0 bps one way.

Buy and hold, same daysValue
Largest one-day gain14.5% on 13 Oct 2008
Largest one-day loss-10.9% on 16 Mar 2020
CAGR without the 10 largest gains6.6%
CAGR without the 30 largest gains1.8%
CAGR without the 10 largest losses16.0%
CAGR without the 30 largest losses22.1%

The days replaced by 0 are the largest daily gains (or losses) of the window.

How MarketHeist computes it

Every choice an implementation has to make, as the code makes it today. The page is checked against the code each time it is built.

ChoiceHow it is computedIn the code
DataDaily bars (open, high, low, close, volume) of the fund as the MarketHeist data service serves them to the backtester: prices adjusted for splits and dividends, so a dividend counts as reinvested. They come from a snapshot taken each month and cut at the data month of this page, and are not rounded. The fund's own history, not an extension: a fund younger than the window is measured over the years it has.
WindowThe worked example and the lab measure the last 20 years of trading days, Oct 2006 to Sep 2026 (5030 days), ending at the data month of this page. Every setup, and buy and hold, is measured over exactly these days; an indicator is warmed up on the days before them, so changing a setting never moves the window, and a setting that needs more history than exists before the window is refused rather than measured over fewer days.
BacktestThe backtester's own engine, in the order it runs it: the indicator, the position rule (or entry and exit triggers) and the optional regime filter produce a position for every day of the fund's whole history; the position is then shifted forward by the execution delay and applied to each day's return over the window. Cash earns 0, there is no leverage, and a one-way cost in basis points is charged on the size of every change of position. Round trips are the closed entries of the trade log (a trade still open on the last day is not counted); the win rate is the share of them with a gain; the payoff ratio is the average win over the size of the average loss; expectancy is the average return per trade; the per-trade profit factor is the sum of the winning trades' returns over the size of the sum of the losing ones, while the per-day profit factor sums days.
Years and volatilityA year is 252 trading days, the engine's convention: trades per year is round trips over days divided by 252, the CAGR is the growth multiple to the power 252 over the days, and volatility is the sample standard deviation of the daily returns times the square root of 252.
Indicator statisticsThe indicator's main output over the window: its last value, its 10th, 50th and 90th percentile (linear interpolation between ranks), and the share of days the rule alone says long, before the delay and any regime filter. Every output of the indicator is also summarized by its median and the share of days below 0.
Buy and holdThe fund held every day of the window with dividends reinvested. The largest one-day gain and loss are the highest and lowest daily returns; the CAGR without the 10 or 30 largest gains (or losses) replaces those days' returns with 0 and recompounds.
Moving averageSimple moving average of the close over <code>ma_window</code> bars (default 52, from 4 to 400), or, with ma_type EMA, an exponential average with weight 2 / (window + 1) on the newest bar, normalised over the bars seen so far (pandas ewm with span and adjust=True).emapackages/shared/engine/utils.ts
SpeedThe average's percentage change over <code>diff_lag</code> bars: M[t] / M[t − lag] − 1 (default lag 4, from 1 to 52).pctChangeLagpackages/shared/engine/utils.ts
AccelerationThe difference of that speed over the same lag: g[t] − g[t − lag].diffpackages/shared/engine/utils.ts
Normalization (the signal)The acceleration divided by its rolling sample standard deviation (divides by n − 1) over 4 × ma_window bars, today included; no value while that window is incomplete or the deviation is 0. This is the primary output the rule reads; the average and its speed are returned alongside it.computepackages/shared/engine/indicators/curvature.ts
Warm-upA first value needs roughly ma_window + 2 × lag + 4 × ma_window bars of history (about 270 bars with the defaults, about 520 for a 100-day average with 10-day steps). The lab takes the warm-up from bars before the test window.
Default ruleLong while the normalized curvature is strictly above 0, otherwise flat.SPECpackages/shared/engine/indicators/curvature.ts
Timing, costs and cashThe position decided at a bar's close is applied to the next bar's return (execution delay 1); no trading costs unless set; cash earns 0.runBacktestpackages/shared/engine/backtest.ts
Engine functionsThe functions the portfolio app and the MarketHeist MCP tools run, called here on the same monthly returns.computePositionpackages/shared/engine/run_basic.tsgeneratePositionpackages/shared/engine/positions.tsapplyRegimeFilterpackages/shared/engine/regime_filter.tsgenerateTriggeredPositionpackages/shared/engine/triggered_position.tsrunBacktestpackages/shared/engine/backtest.tsgetIndicatorpackages/shared/engine/indicators/registry.ts

Moving-average curvature compared with its neighbours

Level, speed and acceleration of a trend
MeasureWhat it readsTurnsNoise
Price above its moving averageLevel against trendWhen the price crosses the averageModerate
Moving-average crossoverShort trend against long trendWhen the short average crosses the long oneLow
Rate of change of the averageSpeed of the trendWhen the average stops risingModerate
Moving-average curvatureAcceleration of the trendWhen the pace of the trend stops increasingHigh
MACD histogramGap between MACD and its signal line, a similar acceleration ideaWhen MACD's own rise slowsHigh

Limitations

  • Two differences amplify noise. With short settings on daily bars the sign flips often, and many of the switches reverse within days.
  • The rule trades often; the zero-cost test overstates what a trader would have kept after spreads and fees.
  • Four settings give many combinations. A setting chosen because it looked good on one history tends to do worse on the next; neighbouring settings are the check.
  • The long normalization window needs a year or more of daily history before the first reading, so young funds have short tests.
  • The test ignores taxes, earns nothing on cash, trades at the close of the signal day and describes one historical path of one fund.

Frequently asked questions

What is the second derivative of a moving average?
The change in its rate of change. The first difference says how fast the average is rising or falling; the second says whether that pace is increasing or decreasing. On daily data both are taken over a lag of a few bars rather than one, to keep the noise down.
Why normalize the curvature?
So that readings are comparable. Raw curvature is tiny and its size depends on the fund's volatility; dividing by its own standard deviation expresses it as a multiple of its typical size. It does not change whether the reading is above or below zero.
Is curvature the same as the MACD histogram?
They share an idea. The MACD histogram is MACD, the difference between a fast and a slow exponential average, minus its own moving average (the signal line); it rises while momentum is building. Curvature takes the change in an average's speed directly. Both turn earlier than trend-level signals and both are noisier.
Why does a curvature rule trade so often?
Because the pace of a trend changes much more often than its direction. Every wobble in the speed of the average flips the sign, so a rule that holds only while the trend is accelerating moves in and out many times a year.

References

  1. Appel, G. (2005) Technical Analysis: Power Tools for Active Investors. FT Prentice Hall. MACD and the histogram as a measure of changing momentum.
  2. Kaufman, P. J. (2013) Trading Systems and Methods. Wiley, fifth edition. Rate of change, acceleration and the noise of differenced trends.
  3. Lo, A. W., Mamaysky, H. and Wang, J. (2000) Foundations of Technical Analysis: Computational Algorithms, Statistical Inference, and Empirical Implementation. Journal of Finance 55(4). Smoothing prices before reading patterns from them.
  4. Brock, W., Lakonishok, J. and LeBaron, B. (1992) Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. Journal of Finance 47(5).

Try it on your own holdings

Run the curvature rule on SPY in the backtester →

Or ask an assistant connected to the MarketHeist MCP server (https://marketheist.io/mcp), which computes the same figures:

Using MarketHeist.io, backtest SPY on daily bars with MA curvature (52-bar simple average, lag 4): hold SPY while the curvature is above 0, otherwise cash, one-bar delay, no costs, over the last 20 years. Report trades per year and compare CAGR and maximum drawdown with buy-and-hold.

Ask an AI assistant

The prompt opens in a new tab, already filled in. An assistant without the MarketHeist connector answers from its own knowledge, not from the figures on this page.

Historical simulation, not advice. Computed by the MarketHeist portfolio engine from monthly total returns, data through Sep 2026. Markdown version of this page: moving-average-curvature.md.