TFO + ATR Strategy with Trailing Stop Loss
Jan 2, 2022

The TFO + ATR Strategy with Trailing Stop Loss indicator provides a trend-following framework that combines Dr. John Ehlers' Trend Flex Oscillator with Average True Range (ATR) volatility filtering to identify long entry and exit points. By filtering oscillator signals through volatility thresholds, the tool aims to capture reversals in bullish market conditions while managing open trades through an integrated trailing stop-loss mechanism.
Usage
The Usage section describes how the script can be used to navigate trend-following scenarios, particularly within cryptocurrency markets. The strategy is primarily designed for long-only positions and functions best on medium-term timeframes such as the 2-hour chart.
- Entering Positions: A long entry is triggered when the Trend Flex Oscillator (TFO) is in an oversold state (below the lower level) and begins to rise, provided the current volatility (ATR) is above the user-defined minimum threshold.
- Exiting Positions: Trades can be closed via two primary methods:
- Strategy Exit: Occurs when the TFO crosses below the upper level while volatility remains above the sell threshold. Users can enforce a minimum profit percentage ("Value must exceed %") before the strategy is allowed to close the position.
- Trailing Stop Loss: A dynamic exit that "arms" once price reaches a specific percentage above the average entry price, thereafter trailing the price by a fixed percentage to lock in gains.
- Pyramiding: The strategy supports up to 15 concurrent long orders, allowing for scaling into positions during extended oversold periods.
Details
The script utilizes a specific implementation of the Trend Flex Oscillator, which incorporates a SuperSmoother filter to reduce lag and noise. The volatility component is derived from the difference between the current ATR and its EMA, expressed as a percentage. This ensures that the strategy only initiates trades during periods of sufficient price action.
Notably, the strategy is designed with a "HODL" bias; it does not feature a traditional hard stop-loss for every trade but instead relies on the trailing stop or a collective strategy close. This makes it highly sensitive to bear market conditions where price may not return to the oscillator's overbought zone for extended periods.
Settings
Back-Testing Start Date
- From Month/Day/Year: Sets the starting point for the strategy's execution and back-testing calculations.
Average True Range
- Min Volatility for Buy: The minimum percentage difference required between current ATR and its average to allow a long entry.
- Min Volatility for Sell: The minimum volatility required to trigger a strategy-based exit.
- Average the Volatility over 3 bars: When enabled, smoothes the volatility data to prevent premature entries or exits due to single-bar spikes.
Trend Flex Oscillator
- TFO Upper/Lower Level: Defines the overbought and oversold thresholds for the oscillator.
- TrendFlex Period: The lookback period used for the Trend Flex calculation.
Selling Conditions
- Allow Strategy to close positions: Enables or disables exits based on TFO and ATR consensus.
- Value (%) must exceed: A minimum profit threshold that must be met before the strategy is allowed to close a trade.
- Set Trailing Stop Loss: Activates the dynamic trailing stop-loss mechanism.
- Trailing Stop Arms At (%): The profit percentage required to activate the trailing stop.
- Trailing Stop Loss (%): The percentage distance the stop-loss maintains behind the price once armed.
FAQ
How do I interpret the volatility settings? The volatility is calculated as the percentage difference between the current ATR and its 18-period EMA. Higher values mean the market is moving more significantly than its recent average, which the strategy uses to confirm trend strength.
What happens if the price drops immediately after entry? Since this strategy is designed with a "HODL" bias, it does not include a standard initial stop-loss. It will remain in the trade until the trailing stop is armed and triggered, or until the Trend Flex Oscillator signals an exit above the user-defined profit threshold.
How can I access the TFO + ATR Strategy with Trailing Stop Loss? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
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.