Supertrend explained, and how to write it as a condition
Supertrend is a single line that sits either below price or above it, and it is only ever in one of those two states. That makes it the simplest trend indicator to read and one of the simplest to write a condition from: there are no levels, no crossings between lines, just which side it is on and the moment it changes.
What it measures
The line is placed a multiple of Average True Range away from price — three times ATR by default, with the ATR measured over ten bars. While price is above the line, the line sits below price and ratchets upward as price rises, never stepping back down. When a bar closes through it, the line flips to the other side and starts ratcheting the other way.
Because the distance is a multiple of ATR, the line sits further from price when the market is moving a lot and closer when it is quiet. A flip therefore needs a bigger move against the trend on a volatile market than on a calm one, which is the whole point of building it on ATR rather than on a fixed distance.
The two settings
- ATR period — how many bars the range is averaged over. Ten is the default.
- Multiplier — how many ATRs away from price the line sits. Three is the default. A smaller multiplier keeps the line close, so it flips more often and follows the market more tightly; a larger one keeps it further away, so it flips rarely and only on a substantial move.
Those two numbers are the whole indicator, and the multiplier is the one that changes its character. A parameter search across it shows whether the setting you chose sits somewhere stable or on a spike.
Writing it as a condition
Four comparisons, in the builder's own words.
- Bullish. The line is below price. A state: true for every bar of the stretch, which can be days or weeks.
- Bearish. The line is above price. The other state.
- Flips bullish. True on the one bar where the line moves from above price to below it. A moment.
- Flips bearish. The reverse flip.
Supertrend(10, 3) on 4h · bullish
Supertrend(10, 3) on 15m · flips bullish
The two uses follow from the two kinds of comparison. The state is a context condition — "the 4-hour trend is up" — that stays true for long stretches and rarely transitions, so it seldom fires an alert on its own. The flip is a trigger: it is true for one bar and completes a strategy at a definite moment. The moving averages guide explains why that difference decides how often you hear from a strategy.
What it shares with a moving average
The lag. Supertrend flips when a bar closes through a line that sits a few ATRs away, so by the time it flips, price has already moved that far. It is late by construction, in exchange for not flipping on every wobble. A long-trending market reads as one unbroken bullish stretch; a ranging market reads as a series of flips in both directions, each one a bar or two behind the turn it reports.
Before you trust it
A flip says the trend as this indicator defines it has just changed on this chart. It does not say the new trend will continue. How the market moved after the flips a strategy would have fired on — over the history tested, on the market tested — is what an entry check reports, and it reports the past.