Tri-State Supertrend
Aug 11, 2023

The Tri-State Supertrend indicator incorporates a range filter into a Supertrend algorithm to identify Buy, Sell, and Range states, helping traders avoid "whipsaw" signals during sideways price action.
Usage
The indicator can be used similarly to a standard Supertrend, where Buy and Sell signals denote potential entry points. The unique "Range" state alerts the user when the price movement fails to reach a specific percentage threshold, indicating a lack of trend.
Traders can interpret the Range state in several ways:
- Trend Continuation: Maintaining an existing position through the range until a new directional signal appears.
- Position Closing: Exiting a trade immediately upon entering a Range state to preserve capital.
- Mean Reversion: Utilizing the Range boundaries for counter-trend scalping (buying at support and selling at resistance).
The "Show suppressed signals" option allows users to see which Buy or Sell signals were filtered out by the range detection logic, providing insight into how much noise is being removed.
Details
This script is built upon the Pivot Point Supertrend logic, which uses pivot highs and lows to determine the center line rather than simple median prices. The "Tri-State" aspect refers to the transition between Bullish, Bearish, and Neutral (Range) modes.
Ranges are detected by monitoring the furthest price move in the direction of the current trend. If the maximum percentage movement during a trend cycle is below the user-defined Range size, the algorithm classifies the subsequent signal as a Range state. This logic remains active on every bar to ensure the indicator can exit the Range mode as soon as a significant move occurs. While this introduces a small delay in trend catching (equal to the range percentage), it significantly reduces false signals during consolidation.
Settings
- Pivot Point Period: Determines the lookback period for calculating pivot highs and lows used for the center line.
- ATR Factor: The multiplier applied to the Average True Range to set the distance of the bands.
- ATR Period: The lookback window for the ATR calculation.
- Range filter: Enables or disables the range detection logic.
- Range size: Sets the percentage threshold that defines a range; moves smaller than this value trigger a Range state.
- Show Pivot Points: Toggles the visibility of 'H' and 'L' markers on the chart.
- Show Buy/Sell Labels: Displays text labels for trade signals.
- Show Support/Resistance: Plots support and resistance levels derived from pivot points.
- Show (non-) trendline for ranges: Controls whether the trailing stop line is visible during Range states.
- Show suppressed signals: Displays labels for directional signals that were ignored due to the range filter.
FAQ
How do I access Tri-State Supertrend?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
What is the advantage of using a range filter?
A range filter reduces the number of false "whipsaw" signals that typically occur when a standard Supertrend is applied to a sideways market.
Does the range filter cause lag?
Yes, there is a minor delay in confirming a new trend because the price must first move beyond the specified "Range size" percentage to exit the Range state.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.