# Rolling Segment

A volatility-adjusted trend line drawn as straight segments that hold their slope until the market state changes. Slow mode keeps it smooth in quiet conditions, Fast mode kicks in when momentum expands, and ATR-based thresholds print triangle markers at trend reversals: a clean, readable framework for trend followers.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Mar 17, 2026.
- Access: free.
- Concepts: [Linear Regression](https://www.luxalgo.com/library/concept/linear-regression/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwn5eiw007mvhsgfqvk9njr
- Page: https://www.luxalgo.com/library/indicator/rolling-segment/

**Rolling Segment** plots a segmented trend line that deliberately refuses to behave like a moving average: it fixes a linear slope (kin to a [linear regression](https://www.luxalgo.com/library/concept/linear-regression/) fit) and holds it frozen until the market state changes. Green segments mark bullish conditions, red segments bearish, and a gradient fill between price and the line shows how far the move has stretched from its reference path.

State means two things: trend direction and speed mode. The ATR scaling the slope refreshes only when a reversal confirms, when a speed-mode change triggers, or on the initial calculation, which is why segments stay straight and readable.

## How to Trade the Rolling Segment?

- **Segment color**: green for bullish, red for bearish, the simplest trend-bias filter available.
- **Triangle markers**: a bullish triangle prints below the segment when a new uptrend begins, a bearish one above it when a downtrend takes over, each confirmed by an ATR-scaled move against the prior trend.
- **Fast mode engaging**: price stretching past the Fast Threshold flips the line steeper, evidence momentum is genuinely expanding.
- **Persistent overextension**: if price keeps pulling away even after Fast mode engages, the move may be overheating; watch for pullback or mean-reversion risk.

A flattening segment signals a market without direction relative to its volatility, a cue to stand down on trend entries until expansion returns.

## Rolling Segment Settings

- **Fast Slope Length**: slope speed during strong trends; lower values track momentum more aggressively.
- **Slow Slope Length**: slope in normal conditions; higher values keep the line flatter and calmer.
- **ATR Length**: lookback for the ATR that scales both the slope and the thresholds.
- **Fast Slope Threshold (ATR Multiplier)**: how far price must run from the segment before Fast mode engages.
- **Reverse Threshold (ATR Multiplier)**: how far price must move against the trend before a reversal confirms.

## Frequently Asked Questions

### Is the Rolling Segment just a disguised moving average?

No. A moving average recalculates every bar and continually reshapes; this line freezes its slope between state changes, advancing at a constant volatility-scaled pace until a reversal or speed switch resets it.

### How does it compare with the Rolling Trendline?

[Rolling Trendline](https://www.luxalgo.com/library/indicator/rolling-trendline/) projects a regression slope inside ATR zones and re-anchors on statistical breaks, while Rolling Segment switches between two fixed slopes and marks reversals with triangles. Both are adaptive trend lines; this one favors readability, that one favors structure.

### Do I need a subscription to use it?

No. Rolling Segment is free on the LuxAlgo Library. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [Linear Regression Histogram](https://www.luxalgo.com/library/indicator/linear-regression-histogram/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/linear-regression-histogram.md
- [Linear Regression Fan](https://www.luxalgo.com/library/indicator/linear-regression-fan/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/linear-regression-fan.md
- [Periodic Linear Regressions](https://www.luxalgo.com/library/indicator/periodic-linear-regressions/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/periodic-linear-regressions.md
- [Rolling Trendline](https://www.luxalgo.com/library/indicator/rolling-trendline/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/rolling-trendline.md
- [Extrapolated Previous Trend](https://www.luxalgo.com/library/indicator/extrapolated-previous-trend/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/extrapolated-previous-trend.md
- [Bitcoin Power Law](https://www.luxalgo.com/library/indicator/bitcoin-power-law/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/bitcoin-power-law.md
- [Recursive Least Squares Forecast](https://www.luxalgo.com/library/indicator/recursive-least-squares-forecast/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/recursive-least-squares-forecast.md
- [Spline Quantile Regression Channel](https://www.luxalgo.com/library/indicator/spline-quantile-regression-channel/) (Polynomial Regression): markdown at https://www.luxalgo.com/library/indicator/spline-quantile-regression-channel.md

---

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