SuperTrend ATR Dual Trend-Following & Volatility-Adaptive Strategy
FMZQuant

FMZQuant @fmzquant

Joined:
Apr 25, 2024

SuperTrend ATR Dual Trend-Following & Volatility-Adaptive Strategy

Publish Date: May 7
1 1

Image description

Image description

Overview
The SuperTrend ATR Dual Trend-Following & Volatility-Adaptive Strategy is a comprehensive trading system based on the SuperTrend indicator and Average True Range (ATR). This strategy utilizes the SuperTrend indicator to identify market trend direction and generate buy and sell signals at trend reversal points. Simultaneously, the strategy employs the ATR indicator to dynamically calculate stop-loss and take-profit levels, enabling it to automatically adjust according to market volatility, thereby improving risk management efficiency. The strategy features fully customizable parameters, including ATR period length, SuperTrend factor, and ATR multipliers for take-profit and stop-loss, allowing traders to fine-tune according to personal preferences and varying market conditions.

Strategy Principles
The core of this strategy lies in combining the advantages of the SuperTrend indicator and ATR indicator to create a trading system that can both capture trends and dynamically manage risk. The specific principles are as follows:

SuperTrend Calculation: The strategy uses the ta.supertrend(factor, atrPeriod) function to calculate the SuperTrend line and direction indicator. The SuperTrend indicator itself is based on ATR, drawing a line above or below the price to indicate the trend. When the price breaks through this line, the trend is considered to have reversed.

Signal Generation:

  • Long Signal: Triggered when the direction indicator changes from negative to positive (direction[1] > direction) and the closing price is above the SuperTrend line
  • Short Signal: Triggered when the direction indicator changes from positive to negative (direction[1] < direction) and the closing price is below the SuperTrend line

Dynamic Stop-Loss and Take-Profit:

  • Long Stop-Loss: Entry price minus the ATR value multiplied by the stop-loss multiplier (close - atrMultiplierSL * atr)
  • Long Take-Profit: Entry price plus the ATR value multiplied by the take-profit multiplier (close + atrMultiplierTP * atr)
  • Short stop-loss and take-profit use the opposite calculation logic

Position Management: The strategy closes positions in the opposite direction when generating new signals, then opens new positions, ensuring that long and short positions are not held simultaneously.

Strategy Advantages

  1. Strong Adaptability: Through the ATR indicator, the strategy can automatically adjust stop-loss and take-profit levels according to market volatility, meaning that in highly volatile markets, stop-loss and take-profit levels will be appropriately widened, while in stable markets they will be narrowed, allowing the strategy to better adapt to different market environments.

  2. Comprehensive Risk Management: Each trade is set with ATR-based stop-loss and take-profit, effectively controlling the risk of individual trades. The stop-loss setting prevents significant losses, while take-profit ensures profit locking.

  3. Clear Signals: The strategy generates trading signals using changes in SuperTrend direction and the relationship between price and the SuperTrend line, with simple and clear signal rules that are easy to understand and execute.

  4. Visual Intuitiveness: The strategy clearly marks buy and sell signals on the chart, and intuitively displays trend direction through color-coded SuperTrend lines and background color changes, enabling traders to easily track market status.

  5. Customizable Parameters: The strategy provides multiple adjustable parameters, including ATR period, SuperTrend factor, and ATR multipliers for take-profit and stop-loss, allowing traders to optimize according to personal risk preferences and trading styles.

Strategy Risks

  1. Trend Reversal Risk: In oscillating markets, the SuperTrend indicator may produce frequent signal reversals, leading to consecutive stop-losses, forming the so-called "sawtooth effect." The solution is to increase the SuperTrend factor value, making the indicator less sensitive to short-term price fluctuations, or temporarily stop trading when oscillating markets are identified.

  2. False Breakout Risk: Markets sometimes exhibit fake breakouts, where the price briefly breaks through the SuperTrend line before returning to the original trend, which may lead to unnecessary trades. This can be mitigated by adding confirmation mechanisms, such as requiring the price to maintain a certain time or magnitude after breakout, to reduce false signals.

  3. Stop-Loss Level Setting Risk: If the ATR multiplier is set too small, the stop-loss point may be too close to the entry price and triggered by normal market fluctuations; if set too large, it may lead to excessive single-trade losses. The solution is to reasonably set the ATR multiplier based on historical backtest data.

  4. Market Sudden Change Risk: During major news or events, the market may experience gaps or extreme volatility, rendering stop-losses ineffective. Consider adding maximum loss limits or reducing positions during periods when major events are expected.

  5. Parameter Optimization Excess Risk: Excessive optimization of strategy parameters may lead to "overfitting," meaning the strategy performs well on historical data but poorly in future actual trading. It is recommended to use sufficiently long historical data and test the strategy's robustness under different market conditions.

Strategy Optimization Directions

  1. Add Filter Mechanisms: Additional technical indicators such as RSI, MACD, or moving average crossovers can be introduced as filters, trading only when the main trend direction is confirmed, reducing false signals. Conditional judgments can be added to the code, for example, executing corresponding long or short signals only when RSI indicates overbought or oversold areas.

  2. Optimize Position Management: The current strategy uses fixed positions, which can be improved to dynamic position management based on ATR or other volatility indicators. Reducing positions during high volatility and increasing positions during low volatility to balance risk and reward.

  3. Add Time Filtering: Some markets may have higher volatility or insufficient liquidity during specific time periods, making them unsuitable for trading. Time filtering conditions can be added to avoid these unfavorable periods.

  4. Multi-Timeframe Analysis: SuperTrend signals from higher timeframes can be introduced as main trend confirmation, executing trades only when the higher timeframe trend direction is consistent with the current timeframe, improving win rates.

  5. Adaptive Parameters: Allow the strategy to automatically adjust parameters according to market conditions, for example, increasing the SuperTrend factor in high-volatility market environments and decreasing the factor value in low-volatility markets. This can be achieved by calculating the rate of change in market volatility or trend strength indicators.

  6. Enhance Risk-Reward Ratio Optimization: The current strategy's take-profit and stop-loss are based on fixed ATR multipliers. Consider implementing dynamic risk-reward ratios, increasing take-profit distance when trends are strong and tightening take-profit when signal strength is weak, to optimize overall risk-reward ratios.

Conclusion
The SuperTrend ATR Dual Trend-Following & Volatility-Adaptive Strategy is a comprehensive trading system based on the SuperTrend indicator and ATR, which captures market opportunities by identifying trend direction and key turning points, while managing risk using dynamic stop-loss and take-profit mechanisms. The main advantages of this strategy lie in its adaptability and risk management capabilities, automatically adjusting trading parameters according to market volatility conditions.

However, the strategy also faces risks such as trend repetition, false breakouts, and parameter settings. The strategy's robustness and profitability can be further improved by adding filter mechanisms, optimizing position management, introducing multi-timeframe analysis, and implementing adaptive parameters.

Overall, this is a trend-following strategy with a solid theoretical foundation, suitable for traders who wish to effectively manage risk while tracking trends. With reasonable parameter settings and continuous optimization, this strategy has the potential to achieve stable trading performance under various market conditions.

Strategy source code

/*backtest
start: 2025-04-21 00:00:00
end: 2025-04-26 03:00:00
period: 2m
basePeriod: 2m
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=6
strategy("SuperTrade ST1 Strategy", overlay=true)

// === INPUTS ===
atrPeriod      = input.int(10, "ATR Length", minval=1)
factor         = input.float(3.0, "Supertrend Factor", minval=0.01, step=0.01)
atrMultiplierTP = input.float(2.0, "Take Profit ATR Multiplier", step=0.1)
atrMultiplierSL = input.float(1.0, "Stop Loss ATR Multiplier", step=0.1)

// === SUPER TREND CALCULATION ===
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
supertrend := barstate.isfirst ? na : supertrend

// === ATR CALCULATION ===
atr = ta.atr(atrPeriod)

// === VARIABLES FOR EXITS ===
var float longStop = na
var float longProfit = na
var float shortStop = na
var float shortProfit = na

// === STRATEGY CONDITIONS ===
longCondition  = direction[1] > direction and close > supertrend
shortCondition = direction[1] < direction and close < supertrend

if (longCondition)
    strategy.close("Short")
    strategy.entry("Long", strategy.long)
    longStop := close - atrMultiplierSL * atr
    longProfit := close + atrMultiplierTP * atr

if (shortCondition)
    strategy.close("Long")
    strategy.entry("Short", strategy.short)
    shortStop := close + atrMultiplierSL * atr
    shortProfit := close - atrMultiplierTP * atr

// === STRATEGY EXITS ===
if (strategy.position_size > 0)
    strategy.exit("Exit Long", from_entry="Long", stop=longStop, limit=longProfit)

if (strategy.position_size < 0)
    strategy.exit("Exit Short", from_entry="Short", stop=shortStop, limit=shortProfit)

// === PLOTTING SUPER TREND ===
plotshape(longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

plot(supertrend, title="Supertrend Line", color=direction < 0 ? color.red : color.green, style=plot.style_linebr)

// === OPTIONAL: Background Color (to show trend) ===
bgcolor(direction < 0 ? color.new(color.red, 90) : color.new(color.green, 90))
Enter fullscreen mode Exit fullscreen mode

Strategy parameters

Image description

The original address: SuperTrend ATR Dual Trend-Following & Volatility-Adaptive Strategy

Comments 1 total

  • Rebecca Chow
    Rebecca ChowJun 5, 2025

    Smart trend-following approach! Combining Supertrend with ATR for volatility adaptation creates a robust system. The dual-layer confirmation really helps avoid false signals during choppy markets.

Add comment