trend indicator
SMA backtesting — Simple Moving Average
The Simple Moving Average (SMA) is the plain average of closing price over a fixed window, plotted as a single smoothed line. It is the most basic trend tool in technical analysis — the question is never whether it draws a smooth line, but whether reacting to it (crosses, slope, price distance) produces an edge on your market.
How SMA works
Each SMA value is the arithmetic mean of the last N closes, recalculated as each new candle closes. Every close in the window counts equally, so the line lags price by roughly half the window length — a longer SMA is smoother and slower, a shorter one hugs price and reacts sooner but whipsaws more in chop. CandleTest computes SMA with TradingView-parity math. It is most often used as a trend filter — price crossing above or below the line, optionally combined with the line’s own slope for confirmation — both testable as no-code rules.
SMA settings
The averaging window in candles. Shorter lengths track price closely and generate frequent crosses; longer lengths smooth out noise but confirm trend changes later.
Example SMA strategies to backtest
Enter long when the close crosses above the SMA line. Exit when the close crosses back below it.
Enter long when the close crosses above the SMA and the SMA itself is rising — confirming the average’s own direction, not just a brief poke through a flat line. Exit when the close crosses back below the SMA, or when the SMA turns to falling.
Every rule above is buildable in the no-code strategy builder — pick conditions, press run, and get win rate, drawdown and equity curve on real exchange data with fees and leverage modeled.
SMA FAQ
Is SMA better than EMA for crypto?
Neither is universally better — SMA weights all candles equally and lags more, while EMA reacts faster but can whipsaw more in choppy markets. The only way to know which suits a given pair and timeframe is to backtest both with the same rule and compare the results.
What SMA length should I use?
It depends entirely on the timeframe and the rule attached to it — there is no setting that works everywhere. Start from a common default and sweep a range of lengths in a backtest to see how sensitive the results are before trusting any single number.
Does a simple price-vs-SMA rule actually work?
It tends to do well in sustained trends and poorly in sideways markets, where price crosses the line repeatedly and each cross gets stopped out. Backtesting over a period that includes both trending and ranging stretches shows the real trade-off.
Can I use SMA crossovers as both entry and exit?
Yes — using the close crossing above the SMA as the entry and crossing back below as the exit is a complete, directly buildable rule. Pairing it with the SMA’s own slope (rising to confirm entries, falling to confirm exits) adds a trend-direction filter without needing a second overlay.