EMA — exponential moving average
A line that follows the average price, with more weight on the newest bars.
About
The EMA is a line that shows the average price of the last few bars. It gives the newest bars more weight.
In KAGAMI, it is called Moving Average Exponential in the Indicators list.
- Click Indicators at the top of the chart.
- Type Moving Average Exponential.
- Click it. The line appears on the chart.
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, EMA, 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.
- Some traders add two EMAs, a short one and a long one. They watch where the two lines cross.
- Some traders watch how far the price has moved away from the line.
An indicator only describes past prices. It cannot tell the future.
The settings
To open the settings, point at EMA at the top left of the chart. Click the Settings button (the gear).
The Inputs tab shows:
- 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.
- 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. Or it has only just started.
- 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 a few bars to catch up.
- Different lengths. A short EMA and a long EMA can point different ways at the same time.
- Other websites. An EMA depends on its first bar. Another site may start from a different bar. So its values can differ a little.
Charts are for learning, not advice. Read our Risk Disclaimer.
An example
Open NASDAQ:AAPL on a 15-minute chart. Each bar is 15 minutes. Add Moving Average Exponential. Keep Length at 9.
These numbers are made up, to show the idea:
- Say the line is at 100.
- The next bar closes at 110.
- With a length of 9, the line moves one fifth of the way there. It goes to 102.
- The next bar closes at 110 again. The line moves one fifth of the way again, to 103.6.
The line moves toward the new price step by step. It does not jump to it.
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:
- Take the Source price of each bar (
closeat the start). - Work out the weight:
α = 2 ÷ (Length + 1). With Length 9,α = 0.2. - The first value is on bar number Length. It is the simple average of the first Length prices.
- Every later bar:
EMA = α × price + (1 − α) × EMA of the bar before. - Offset moves the drawn line by that many bars. It does not change the values.
- Smoothed MA, when turned on: an average of the EMA values over Smoothing Length bars. Smoothing Line picks the kind of average:
SMA(simple),EMAorWMA(weighted, newest bar heaviest).
α = 0.2). The numbers under the columns are bars ago. The newest bar (0) counts 20%, the one before 16%, then 12.8%. Each older bar counts 0.8 times the bar after it.Inputs
| Input | Default | Range / options | What it does |
|---|---|---|---|
| Length | 9 | 1 to 10,000, whole numbers | The number of bars in the average. Sets the weight α. |
| Source | close | open, high, low, close, hl2, hlc3, ohlc4 | The price used for each bar. |
| Offset | 0 | −10,000 to 10,000 | Moves the line right (a positive number) or left (a negative number) by that many bars. |
| Smoothing Line | SMA | SMA, EMA, WMA | The kind of average used for the Smoothed MA line. |
| Smoothing Length | 9 | 1 to 10,000, whole numbers | The 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 EMA 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 EMA. 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: 20, 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. The first value is the simple average of the first Length closes. Then
EMA = α × close + (1 − α) × EMA of the bar before, withα = 2 ÷ (Length + 1). - Where it starts: the servers fetch up to 300 extra bars before the part of the chart being drawn. So the line is usually settled at the left edge. Bars before the first value get no point.
- Rounding: values are rounded to 6 decimal places.
- Colours: a length of 20 is indigo,
#6366F1in the dark theme and#4F46E5in the light theme. A length of 50 is amber,#F59E0Bdark and#D97706light. A length of 200 is grey,#8B90A8dark and#5B607Alight. Any other length is indigo, like 20. The line is 1 pixel wide.
How it differs from the built-in:
- It starts at a length of 20, not 9.
- It always uses the close. It has no Source, Offset or Smoothed MA.
- It starts from the servers' first bar, not the chart's. So the two can differ a little, mostly on the left. The difference fades with every new bar.
- Its values come from KAGAMI's servers, not from your browser.
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. One exception: when you scroll far back, the chart loads older bars. It then works the line out again from the new first bar. Values can shift a little, mostly near the old left edge.
- 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 9-bar EMA covers 2 hours 15 minutes on a 15-minute chart. On a daily chart, it covers 9 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 weight is 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 EMA moves only part of the way, by the weight
α. - Length larger than the bars loaded: no line until the chart loads more bars.