SuperTrend
A line that shows the trend and flips when the price crosses it.
About
SuperTrend is a line that follows the trend. It sits under the price in an up trend, and over it in a down trend. A trend is the general direction of the price.
In KAGAMI, it is called SuperTrend in the Indicators list.
- Click Indicators at the top of the chart.
- Type SuperTrend.
- Click it. The line appears on the chart.
It is free for every account.
What you see on the chart
- One thick line, drawn over the price bars. A bar, also called a candle, is one slice of time.
- In an up trend, the line is green and sits under the price.
- In a down trend, the line is dark red and sits over the price.
- When the trend turns up, a green arrow appears under that bar.
- When the trend turns down, a red arrow appears over that bar.
- The line does not start on the very first bar. With the first settings, it starts on bar 11.
- Its name, SuperTrend, shows at the top left of the chart.
Opened KAGAMI from a link and see lines you did not add? They may be KAGAMI's own version. See KAGAMI's own version.
How traders often read it
- Many traders read a green line as an up trend. They read a red line as a down trend.
- Some traders watch the arrows. They mark the bars where the trend turned.
- Some traders watch the line as a level that follows the price. In an up trend, it only moves up or stays flat.
An indicator only describes past prices. It cannot tell the future.
The settings
To open the settings, point at SuperTrend at the top left of the chart. Click the Settings button (the gear).
The Inputs tab shows:
- Length — how many bars are used to measure the usual size of a bar. It starts at 10.
- Factor — how far the line sits from the price. It starts at 3. A bigger number puts the line further away, so it turns less often.
The Style tab changes the line and the arrows. You can hide the arrows there.
When it can mislead
- Sideways markets. Sometimes the price moves up and down with no clear direction. Then the line turns again and again.
- It is late. The line turns only after the price has crossed it.
- Gaps. A price can jump between two bars, for example overnight on a stock. One gap can turn the line at once.
- The last candle. The newest candle is still forming. Its colour can change, and its arrow can appear and go, until the candle closes.
- Few bars. With only a few bars, there is no line yet.
- Where the chart starts. The first part of the line depends on the first bar the chart has. Scrolling back can change it.
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 SuperTrend and keep the settings.
These numbers are made up, to show the idea:
- Say a bar's middle price is 100. That is its high plus its low, divided by 2.
- Say bars move about 2 each, on average.
- With a Factor of 3, the line sits 3 × 2 = 6 away. In an up trend, that is 94.
- The trend is up, so you see a green line at 94.
- Later, a bar closes below the green line.
- The trend turns down. The line jumps over the price and turns red. A red arrow appears over that bar.
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:
- True range (TR) of each bar:
TR = max(high − low, |high − close of the bar before|, |low − close of the bar before|). The first bar has no bar before it, so it has no true range. - ATR, the average true range, Wilder's way. The first ATR is the simple average of the first Length true ranges. After that:
ATR = (TR + ATR of the bar before × (Length − 1)) ÷ Length. - Basic bands:
middle = (high + low) ÷ 2,basic upper = middle + Factor × ATR,basic lower = middle − Factor × ATR. - The lower band keeps its old level unless the basic lower is higher, or the close of the bar before was under the old lower band. So in an up trend it only rises or stays level.
- The upper band keeps its old level unless the basic upper is lower, or the close of the bar before was over the old upper band. So in a down trend it only falls or stays level.
- The line is the lower band in an up trend and the upper band in a down trend.
The direction, bar by bar:
- When the ATR of the bar before has no value yet: down.
- When the line of the bar before was the upper band: up if the close is over this bar's upper band, else down.
- When the line of the bar before was the lower band: down if the close is under this bar's lower band, else up.
middle ± Factor × ATR with Factor 3. 1 — in the up trend, the line is the lower band. The basic lower band dips, but the line keeps its level. 2 — the close falls under the line, so the direction turns down. The line is now the upper band. 3 — in the down trend, the basic upper band rises, but the line keeps its level.The first Length bars show nothing. The first value is on bar number Length + 1. It starts in the down state, so that first bar also gets a down arrow.
Inputs
| Input | Default | Range / options | What it does |
|---|---|---|---|
| Length | 10 | 1 to 100, whole numbers | The number of bars in the ATR. |
| Factor | 3 | 1 to 100, decimals allowed | How many ATRs the bands sit from the middle price. |
The arrows
- Up Arrow: under the bar where the direction turns from down to up.
- Down Arrow: over the bar where the direction turns from up to down. Also on the first bar with a value, because the line starts in the down state.
- One arrow at most per bar. Bars where the direction stays the same get none.
Colours
- SuperTrend (the line): dark green
#008000in an up trend, maroon#800000in a down trend. 3 pixels wide, 35% transparent. - Up Arrow: green
#00FF00, 35% transparent. - Down Arrow: red
#FF0000, 35% transparent.
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 SuperTrend. 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 and multiplier: 10 and 3, unless the link asks for other numbers. The multiplier may have decimals.
- True range: on the first bar,
high − low. After that, the same as the built-in. - ATR: on the first bar, the ATR is that bar's true range. After that:
ATR = (ATR of the bar before × (Length − 1) + TR) ÷ Length. - New bands:
(high + low) ÷ 2 ± multiplier × ATR. On the first bar, the bands are just these. - Lower band, after the first bar: the higher of the new lower band and the old one, if the close of the bar before was over the old lower band. Otherwise the new lower band.
- Upper band, after the first bar: the lower of the new upper band and the old one, if the close of the bar before was under the old upper band. Otherwise the new upper band.
- The direction: it starts up, on the very first bar. In a down trend, it turns up when the close is over the upper band of the bar before. In an up trend, it turns down when the close is under the lower band of the bar before.
- The line: the lower band in an up trend, the upper band in a down trend. There is a value from the first bar the servers fetched. The servers fetch up to 300 extra bars before the part of the chart being drawn.
- Rounding: values are rounded to 6 decimal places.
- Look: two lines, 2 pixels wide. Green while the trend is up:
#22C55Ein the dark theme,#16A34Ain the light theme. Red while it is down:#EF4444dark,#DC2626light. No arrows.
How it differs from the built-in:
- The start. It has a value from its first bar. The built-in waits Length bars.
- The first ATR. It starts from the first bar's
high − low. The built-in starts from the average of the first Length true ranges. - The first direction. It starts up. The built-in starts down.
- The turn. It compares the close with the band of the bar before. The built-in compares it with this bar's band, which may already have moved toward the price. So the two can turn on different bars.
- A close exactly on the old band. It then starts the band fresh. The built-in keeps the tighter of the old and the new band.
- The look. Two thinner lines in KAGAMI's green and red, with no arrows.
- The source. Its values come from KAGAMI's servers, not from your browser.
Because of these, the two versions can show different colours on some bars.
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. Its value, its colour and its arrow can change until the candle closes. After that, they stay.
- Past values do not change, as long as the bars stay the same. One exception: when you scroll far back, the chart loads older bars. It then works the line out again from the new first bar. The start of the line, and sometimes its colour, can change 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 and colour can also change 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. On a short timeframe, the ATR measures small moves. So the line sits close and turns more often.
- 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. A night or weekend gap shows up in the next bar's true range.
Edge cases
- Fewer than Length + 1 bars: the built-in draws nothing.
- Flat prices: the true range is zero, so the ATR shrinks toward zero. The line moves close to the price.
- A big gap: it enters the true range at once. The ATR jumps, and the close can cross the line in one bar.
- A high Factor: the line sits far away and rarely turns.