# Halftrend

Halftrend is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

A definitive clean rebuild of the Halftrend stop-and-reverse line: in up states it steps higher only on rising lowest lows beneath price, in down states only on falling highest highs above it, holding still through consolidation. A half-ATR channel marks the tolerance zone, arrows mark flips, and a gradient fill spans price and the line. Defaults: amplitude 2, channel deviation 2.0, 100-bar ATR.

- Indicator in the LuxAlgo Library, by LuxAlgo, published May 8, 2026.
- Access: free.
- Concepts: [Halftrend](https://www.luxalgo.com/library/concept/halftrend/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=rk2onoqjnua42xfvxzbes7ep
- Page: https://www.luxalgo.com/library/indicator/halftrend/

**Halftrend** rebuilds the community-bred [Halftrend](https://www.luxalgo.com/library/concept/halftrend/) trail as one stepped line with two states. While up, the line follows the running floor of the lowest lows over the amplitude window beneath price; while down, the running ceiling of the highest highs above it. A flip requires the averaged highs (or lows) to cross the tracked level, confirmed by a close past the prior bar's extreme, and the line carries unchanged through the flip bar, staying continuous where jump-style trails gap. A channel sized from half the ATR wraps the line as a tolerance zone, and a vertical gradient fills the span between price and the line.

## How to Trade the Halftrend?

- **Bullish flip arrow**: the state turned up. The line now trails beneath price and gates long exposure.
- **Bearish flip arrow**: the mirror event, the line stepping down overhead.
- **Flat line**: the amplitude window has produced no fresh extreme. The trend is paused, not broken, and a stop referenced to the line has held.
- **Channel rejection**: a wick into the channel that closes back outside it reads as continuation pressure in the standing state's direction.

In tight ranges arrows alternate quickly. Flips are state changes, not automatic trades.

## Halftrend Settings

- **Amplitude** (default 2): lookback of the extreme tracking and the flip-driving averages; larger values hold stiller lines but concede more at turns.
- **Channel Deviation** (default 2.0): multiplier on half the ATR that sizes the tolerance channel.
- **ATR Length** (default 100): a long averaging window, so the channel breathes slowly.
- **Signal On Bar Close** (default disabled): fire arrows and alerts only once the bar closes, removing intrabar provisionality.
- **Style toggles**: the ATR channel, flip arrows and gradient trail fill are on by default; line width defaults to 2.

## Frequently Asked Questions

### How does Halftrend differ from Supertrend?
Both are stop-and-reverse trails, but [Supertrend](https://www.luxalgo.com/library/indicator/supertrend/) holds its line an ATR-scaled distance from price, adjusting continuously with volatility, while Halftrend moves only when its amplitude window prints a new extreme. The cost is lag at genuine turns, where Halftrend waits for its crossing condition.

### Do wicks into the channel threaten the trend state?
No. The channel is there to absorb them. A poke into it is expected behavior; this build only treats a wick that closes back outside the channel as an event, firing the channel rejection alerts.

### When should Signal On Bar Close be enabled?
When acting on live alerts: a flip condition that appears mid-bar and vanishes by the close never signals, so each printed arrow is final. Historical bars are unaffected: every historical close is already confirmed.

## Related indicators

- [SuperTrend AI (Clustering)](https://www.luxalgo.com/library/indicator/supertrend-ai-clustering/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-ai-clustering.md
- [KNN Supertrend Horizon](https://www.luxalgo.com/library/indicator/knn-supertrend-horizon/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/knn-supertrend-horizon.md
- [Supertrend Parameter Sensitivity 3D](https://www.luxalgo.com/library/indicator/supertrend-parameter-sensitivity-3d/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-parameter-sensitivity-3d.md
- [SuperTrend Recovery](https://www.luxalgo.com/library/indicator/supertrend-recovery/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/supertrend-recovery.md
- [Evasive SuperTrend](https://www.luxalgo.com/library/indicator/evasive-supertrend/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/evasive-supertrend.md
- [Gann HiLo Activator](https://www.luxalgo.com/library/indicator/gann-hilo-activator/) (Trend): markdown at https://www.luxalgo.com/library/indicator/gann-hilo-activator.md
- [Trend Magic](https://www.luxalgo.com/library/indicator/trend-magic/) (Trend): markdown at https://www.luxalgo.com/library/indicator/trend-magic.md
- [SuperIchi](https://www.luxalgo.com/library/indicator/superichi/) (Supertrend): markdown at https://www.luxalgo.com/library/indicator/superichi.md

---

Source: https://www.luxalgo.com/library/indicator/halftrend/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
