← Back to Home
Trading Signal / Indicator
πŸ“Š

Simple Moving Average (SMA)

The foundational trend indicator every trader should know.

Start Automating Free β†’

Want to automate this strategy? Try auto-Trading free β€” no credit card required.

Simple Moving Average (SMA) chart

Overview

What is Simple Moving Average (SMA)?

The Simple Moving Average (SMA) is the arithmetic mean of a specified number of price periods. It is the most basic form of moving average and the starting point for understanding all other moving average derivatives. The 200-day SMA, for example, is one of the most widely cited technical levels in all of financial markets.

Calculation is straightforward: sum the closing prices over N periods and divide by N. As a new candle closes, the oldest price drops off and the newest is added. This creates a smooth line that filters out short-term noise and reveals the underlying trend direction.

The SMA is slower to react to price changes than the EMA, which makes it less prone to false signals in choppy markets but means it lags more on fast-moving trends. For long-term trend analysis β€” where the goal is to identify the broad direction rather than precise entry timing β€” the SMA's smoothness is an advantage.

Key uses include: the 50 and 200 SMA as major support/resistance levels; the 200 SMA as a bull/bear market divider; SMA crossovers as trend change signals; and SMAs applied to volume or RSI (rather than price) for smoothed momentum readings.

How It Works in auto-Trading

Automate It

auto-Trading supports SMA calculation on price (open, high, low, close), volume, and any derived indicator value. In the strategy builder, users configure the SMA period and source and connect the output to a crossover block, a threshold comparison, or a support/resistance monitor. Multiple SMAs can be stacked on the same chart to create multi-timeframe trend frameworks.

Try Free β†’

Strategy Code

Pick a script below, copy it, and use it on your chart.

Pine Script (TradingView)

This is a TradingView Pine Script example for this indicator. Paste it into the TradingView Pine Editor, add it to your chart, and adjust inputs for your market and timeframe.

//@version=6
strategy("Simple Moving Average (SMA)", overlay=true)
fastLen = input.int(20, "Fast Length")
slowLen = input.int(50, "Slow Length")
fast = ta.ema(close, fastLen)

Get full strategy code access

Enter your email address and full name to unlock this strategy code.

ThinkScript (thinkorswim)

This is a thinkorswim ThinkScript example for this indicator. Open thinkorswim, create a custom study, paste the script, and apply it to your chart.

input fastLength = 20;
input slowLength = 50;
def fastSMA = Average(close, fastLength);
def slowSMA = Average(close, slowLength);
def buySignal = fastSMA crosses above slowSMA;

Get full strategy code access

Enter your email address and full name to unlock this strategy code.

Ready to automate Simple Moving Average (SMA)?

Join thousands of traders who use auto-Trading to execute this strategy automatically, 24/7.

Get Started Free β†’

All Strategies & Signals

Continue Learning

Trading Strategies

Trading Signals & Indicators