About

The SMA is a line. It shows the plain average price of the last few bars. Every bar counts the same.

In KAGAMI, it is called Moving Average in the Indicators list.

  1. Click Indicators at the top of the chart.
  2. Type Moving Average.
  3. Click the one named exactly Moving Average. The list also has other kinds, like Moving Average Exponential.

It is free for every account.

What you see on the chart

  • One blue line, drawn over the price bars. A bar, also called a candle, is one slice of time.
  • The line follows the price, but more smoothly.
  • The line does not start on the very first bar. It needs a few bars first. With the first settings, it needs 9.
  • Its short name, MA, shows at the top left of the chart.

Opened KAGAMI from a link and see a line you did not add? It may be KAGAMI's own version. See KAGAMI's own version.

How traders often read it

  • Many traders read the slope of the line as the trend. A trend is the general direction of the price.
  • Some traders watch whether the price is above or below the line.
  • On a daily chart, many traders watch a 50-bar and a 200-bar average.
  • When a short average crosses above a long one, some call it a "golden cross". The opposite is often called a "death cross".
A daily chart of AAPL with a blue MA 9 line following the candles. The line slopes up under a rising price, the price then closes below it, and later the line slopes down above a falling price.A daily chart of AAPL with a blue MA 9 line following the candles. The line slopes up under a rising price, the price then closes below it, and later the line slopes down above a falling price.
AAPL, daily candles, with the Moving Average (MA 9). 1 — in a rise, the line slopes up under the price. 2 — the price closes below the line as the rise ends. 3 — in a fall, the line slopes down above the price.

An indicator only describes past prices. It cannot tell the future.

The settings

To open the settings, point at MA at the top left of the chart. Click the Settings button (the gear).

The Inputs tab shows:

  • Other Symbol — empty at the start. Pick a market here to draw the average of that market instead.
  • Length — how many bars the average covers. It starts at 9. A bigger number gives a smoother, slower line.
  • Source — which price of each bar is used. It starts at close, the last price of the bar.
  • Offset — moves the whole line left or right by a number of bars. It starts at 0.
  • Smoothing Line and Smoothing Length — these set a second, smoother line called Smoothed MA. That line is hidden at the start. You can turn it on in the Style tab.

The Style tab changes the colour and thickness of the lines.

When it can mislead

  • It is late. The line follows the price. So it turns after the price has already turned.
  • Old bars count fully. An old bar counts as much as a new one, until it leaves the average. When it leaves, the line can move even if the price stays still.
  • Sideways markets. Sometimes the price moves up and down with no clear direction. Then it crosses the line again and again. Those crosses say little.
  • Few bars. With only a few bars, there is no line yet.
  • The last candle. The newest candle is still forming. Its value moves until the candle closes.
  • Gaps. A price can jump between two bars, for example overnight on a stock. The line needs many bars to catch up.

Charts are for learning, not advice. Read our Risk Disclaimer.

An example

Open NASDAQ:AAPL on a daily chart. Each bar is one day. Add Moving Average. Keep Length at 9.

These numbers are made up, to show the idea:

  1. Say the last nine bars all closed at 100. The line is at 100.
  2. A new bar closes at 109.
  3. The oldest bar leaves the average. The new bar comes in.
  4. The new average is 101. That is eight bars at 100 plus one at 109, divided by 9.
A line chart. Grey dots sit at 100, then jump to 109 and stay there. A blue line starts at 100 and climbs in equal steps to 109. A shaded box covers nine dots: eight at 100 and the first one at 109.A line chart. Grey dots sit at 100, then jump to 109 and stay there. A blue line starts at 100 and climbs in equal steps to 109. A shaded box covers nine dots: eight at 100 and the first one at 109.
The example as a picture. The grey dots are the closes; the blue line is the MA 9. The shaded part is the nine bars in the average when it is 101: eight at 100 and one at 109. Each new bar pushes the oldest one out, so the line climbs 1 with every bar and reaches 109 after nine bars.

Each new bar pushes the oldest bar out of the average.

Technical details

This part is for readers who want the exact rules. It describes the chart's built-in version first, then KAGAMI's own version.

The calculation

The chart's built-in version works it out in your browser, on the bars the chart has loaded:

  1. Take the Source price of each bar (close at the start). If Other Symbol is set, take that market's price, matched to the chart's bars by time.
  2. SMA = (sum of the last Length prices) ÷ Length.
  3. The first value is on bar number Length.
  4. Offset moves the drawn line by that many bars. It does not change the values.
  5. Smoothed MA, when turned on: an average of the SMA values over Smoothing Length bars. Smoothing Line picks the kind of average: SMA (simple), EMA (exponential) or WMA (weighted, newest bar heaviest).
A column chart over 16 bars. The nine newest bars, on the right, have columns of the same height, 11.1%. The older bars, on the left, have no column.A column chart over 16 bars. The nine newest bars, on the right, have columns of the same height, 11.1%. The older bars, on the left, have no column.
How much each bar counts in an MA 9. The numbers under the columns are bars ago. The nine newest bars (0 to 8) count the same: one ninth each, about 11.1%. Older bars count nothing.

Inputs

InputDefaultRange / optionsWhat it does
Other Symbolemptyany marketEmpty = the chart's own market. Otherwise the line is the average of that market's prices.
Length91 to 10,000, whole numbersThe number of bars in the average.
Sourcecloseopen, high, low, close, hl2, hlc3, ohlc4The price used for each bar.
Offset0−10,000 to 10,000Moves the line right (a positive number) or left (a negative number) by that many bars.
Smoothing LineSMASMA, EMA, WMAThe kind of average used for the Smoothed MA line.
Smoothing Length91 to 10,000, whole numbersThe number of bars in the Smoothed MA average.

The Source short names: hl2 = (high + low) ÷ 2, hlc3 = (high + low + close) ÷ 3, ohlc4 = (open + high + low + close) ÷ 4.

Colours

  • Plot (the SMA line): blue #2196F3, 1 pixel wide, solid.
  • Smoothed MA: hidden at the start.

These are the chart's own defaults. KAGAMI does not change them. You can change them in the Style tab.

KAGAMI's own version

KAGAMI's servers also have their own SMA. It is not in the Indicators list. The chart shows it only when it is opened from a link that already asks for it. Your browser does no maths for it. It only draws the values the servers send.

  • Length: 50, unless the link asks for another number. A link cannot change anything else.
  • Price: always the close of each bar.
  • The maths: the same as the built-in. SMA = (sum of the last Length closes) ÷ Length. The first value is on bar number Length.
  • Where it starts: the servers fetch up to 300 extra bars before the part of the chart being drawn. So the line usually reaches the left edge. Bars before the first value get no point.
  • Rounding: values are rounded to 6 decimal places.
  • Colour: grey, #8B90A8 in the dark theme and #5B607A in the light theme, for every length. The line is 1 pixel wide.

How it differs from the built-in:

  • It starts at a length of 50, not 9.
  • It always uses the close of the chart's own market. It has no Other Symbol, Source, Offset or Smoothed MA.
  • Its colour is grey, not blue.
  • Its values come from KAGAMI's servers, not from your browser.

On the same bars with the same length, the two give the same values. An SMA only looks at its last Length bars, so the first bar does not matter.

When values change

  • The built-in is worked out again each time the chart gets new prices. That is about every 15 seconds on most charts.
  • The newest candle is still forming, so its value moves with the price. Once the candle closes, its value stays.
  • Past values do not change, as long as the bars they use stay the same.
  • KAGAMI's own version asks the servers for new values every 5 to 60 seconds, depending on the chart. Its newest value also moves until the candle closes.
  • Indicators you add are not saved. They are gone when you reload the page.

Timeframes

  • It works on every timeframe. The timeframe is how much time each bar covers.
  • Length counts bars, not time. A 50-bar SMA covers 12 hours 30 minutes on a 15-minute chart. On a daily chart, it covers 50 trading days.
  • Crypto charts also have timeframes of 1, 5, 10, 15 and 30 seconds. Stocks and FX start at 1 minute.
  • The line runs from bar to bar. Nights, weekends and holidays without bars are simply skipped.

Edge cases

  • Fewer bars than Length: no line.
  • Length 1: the line equals the Source price of each bar.
  • Flat prices: the line is flat at that price.
  • A big jump between two bars: the new bar counts fully for Length bars. When it leaves the average, its share drops out again.
  • Other Symbol with different trading hours: its prices are matched to the chart's bars by time. The two markets' bars may not line up one to one.
  • Length larger than the bars loaded: no line until the chart loads more bars.