Adaptive ATR Trailing Stop Double Bottom Breakout Quantitative Trading Strategy
FMZQuant

FMZQuant @fmzquant

Joined:
Apr 25, 2024

Adaptive ATR Trailing Stop Double Bottom Breakout Quantitative Trading Strategy

Publish Date: Jul 11
2 1

Strategy Overview
The Adaptive ATR Trailing Stop Double Bottom Breakout Quantitative Trading Strategy is a trading system that combines classic technical pattern recognition with modern quantitative risk management. The strategy focuses on identifying double bottom reversal patterns in the market and utilizes a dynamic ATR (Average True Range) trailing stop mechanism to protect profits and limit losses. The strategy also incorporates a 50-period Exponential Moving Average (EMA) as a trend filter, ensuring that trade direction aligns with the main trend, thereby increasing the success rate of trades. This strategy is particularly suitable for markets with clear trends, such as gold, stock indices, and individual stocks, enabling systematic capture of opportunities arising from market reversals.

Strategy Principles
The core principle of this strategy is based on trading the double bottom pattern in price structures, a classic technical analysis formation that typically signals a potential end to a downtrend and the beginning of an uptrend. The strategy implementation includes the following key components:

  1. Double Bottom Pattern Recognition: Automatically detects double bottom structures in the market using Pivot Low techniques. The strategy tracks the three most recent lows, confirming a double bottom formation when the first and third low points are at similar price levels (within a specified tolerance range), and the second low point is higher than these two points.

  2. EMA Trend Filtering: Optionally uses a 50-period EMA as a trend confirmation tool. Long entries are only permitted when the price is above the EMA, ensuring that the trade direction aligns with the broader trend.

  3. ATR Volatility Assessment: The strategy calculates and monitors the ATR indicator, considering entry only when market volatility reaches a minimum threshold, avoiding false signals in low-volatility markets.

  4. Dynamic Trailing Stop: Employs an ATR-based trailing stop mechanism where the stop level automatically adjusts as the price rises, protecting profits while giving the price sufficient room to breathe. The stop distance is determined by the current ATR value multiplied by a user-defined multiplier, making it adaptive to the volatility characteristics of different market environments.

  5. Date Range Control: The strategy includes built-in backtest date range control functionality, allowing users to precisely define the historical interval for backtesting, facilitating assessment of strategy performance across different market phases.

Strategy Advantages

  1. Synergy of Pattern and Trend: By combining double bottom pattern recognition with EMA trend filtering, the strategy can screen for high-quality trading signals, entering only when supported by the trend, significantly improving the win rate.

  2. Adaptive Risk Management: The ATR-based dynamic trailing stop mechanism is a major highlight of this strategy, automatically adjusting stop levels based on current market volatility, providing appropriate risk control in different volatility environments.

  3. Volatility Filtering: By setting a minimum ATR threshold, the strategy avoids trading in insufficient volatility market environments, reducing false breakout signals that may occur during low volatility periods.

  4. High Customizability: The strategy offers multiple adjustable parameters, including pivot period, tolerance percentage, ATR length, stop loss multiplier, etc., allowing users to optimize and adjust according to different trading instruments and personal risk preferences.

  5. Real-time Alert System: The built-in JSON format alert functionality enables the strategy to integrate seamlessly with external systems (such as automated trading platforms or notification services), facilitating real-time monitoring and execution.

  6. Visualization of Trailing Stop: The strategy provides visual display of the trailing stop line, helping traders intuitively understand the current risk level and potential exit points.

Strategy Risks

  1. False Breakout Risk: Despite using trend filtering and volatility requirements, double bottom patterns may still produce false breakout signals, especially in sideways consolidation zones or environments with high market noise. Solutions include adding pattern confirmation requirements or delaying entry until confirmation of a breakout pullback.

  2. Parameter Sensitivity: Strategy performance is relatively sensitive to parameter settings (such as pivot period, tolerance percentage, and ATR multiplier). Inappropriate parameter settings may lead to overtrading or missing effective signals. It is recommended to determine the most suitable parameter combinations for specific trading instruments through extensive historical backtesting.

  3. Trend Dependency: The strategy performs best in markets with clear trends and may underperform in sideways consolidation or frequently changing direction market environments. The strategy can be optimized by adding market type recognition logic to adopt different trading parameters or suspend trading in different market states.

  4. Unidirectional Trading Limitation: The current strategy only supports long trades and cannot capture opportunities in falling markets. This may result in missed potential profit opportunities during bear markets or long-term downtrends.

  5. Gap Risk for Stop Loss: In volatile markets or after major news releases, prices may gap open and directly breach the stop level, resulting in actual stop loss prices far below expected levels, increasing trading losses. When using this strategy, consider setting a maximum stop loss amount as additional protection.

Strategy Optimization Directions

  1. Bidirectional Trading Expansion: The current strategy only implements long functionality; adding double top pattern recognition logic can implement short functionality, making the strategy equally effective in falling markets, thereby increasing overall trading opportunities and improving capital utilization efficiency.

  2. Multiple Timeframe Analysis: Introducing multiple timeframe analysis can significantly enhance the robustness of the strategy. For example, using the trend direction of a higher timeframe as the primary filtering condition while looking for entry signals on a lower timeframe. This "top-down" approach typically improves signal quality.

  3. Additional Confirmation Indicator Integration: Consider integrating additional technical indicators as confirmation tools, such as Relative Strength Index (RSI), Stochastic, or volume analysis, requiring multiple indicators to jointly confirm before executing trades, thereby reducing false breakout risk.

  4. Dynamic Position Management: Implement a dynamic position management system based on market volatility and trade confidence, increasing position size when signal strength is higher or market conditions are more favorable, and reducing exposure otherwise, optimizing capital efficiency and risk-adjusted returns.

  5. Market State Adaptability: Develop a market state recognition module enabling the strategy to automatically identify whether the current market is in a trending, oscillating, or transitional state, and adjust trading parameters or suspend trading accordingly, improving the strategy's environmental adaptability.

  6. Machine Learning Optimization: Consider using machine learning techniques to optimize parameter selection and pattern recognition processes. For example, models can be trained to identify double bottom pattern features most likely to succeed or automatically select optimal parameter combinations for different market conditions.

  7. Stop Loss Strategy Refinement: Implement segmented stop loss strategies, such as raising the stop loss to the cost line after a trade reaches a specific profit level or setting profit locking mechanisms, protecting profits while giving the price sufficient room for fluctuation.

Summary
The Adaptive ATR Trailing Stop Double Bottom Breakout Quantitative Trading Strategy is a systematic trading method that combines traditional technical analysis concepts with modern quantitative trading techniques. It generates high-quality long signals by identifying double bottom reversal patterns in the market, combined with EMA trend filtering and ATR volatility assessment. The core advantage of the strategy lies in its adaptive risk management system, especially the ATR-based dynamic trailing stop mechanism, which automatically adjusts protection levels based on market volatility.

Although the strategy has certain limitations, such as supporting only unidirectional trading and sensitivity to parameter settings, these limitations can be effectively overcome through suggested optimization directions such as bidirectional trading expansion, multiple timeframe analysis, and dynamic position management. The high customizability of the strategy enables it to adapt to different trading instruments and market environments, making it particularly suitable for traders seeking reversal opportunities in markets with clear trends.

By deeply understanding the strategy principles and making appropriate adjustments according to personal trading style, traders can develop this strategy into a robust trading system, capturing reversal opportunities in the market while maintaining reasonable risk control.

Strategy source code

/*backtest
start: 2024-06-24 00:00:00
end: 2025-06-22 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=6
strategy("Double Bottom Strategy (Long Only, ATR Trailing Stop + Alerts)", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// === INPUTS === //
prd         = input.int(5, "Pivot Period")
tolerance   = input.float(15.0, "Tolerance %", step=0.1)
atrLen      = input.int(14, "ATR Length")
atrMult     = input.float(1.5, "Trailing Stop ATR Multiplier")
minAtr      = input.float(0.1, "Minimum ATR to enter trade")
useEMAFilter= input.bool(true, "Use 50 EMA Trend Filter?")
showTrail   = input.bool(true, "Show Trailing Stop Line")

// === INDICATORS === //
atr = ta.atr(atrLen)
ema50 = ta.ema(close, 50)
trail_offset = atr * atrMult

// === BACKTEST DATE RANGE === //
startYear  = input.int(2020, "Start Year")
startMonth = input.int(1, "Start Month")
startDay   = input.int(1, "Start Day")

endYear    = input.int(2025, "End Year")
endMonth   = input.int(12, "End Month")
endDay     = input.int(31, "End Day")

inDateRange = (time >= timestamp(startYear, startMonth, startDay, 00, 00)) and
              (time <= timestamp(endYear, endMonth, endDay, 23, 59))

// === PIVOT LOWS === //
pl = ta.pivotlow(low, prd, prd)

// === TRACK LAST 3 LOWS === //
var float p1 = na
var float p2 = na
var float p3 = na
var int i1 = na
var int i2 = na
var int i3 = na

if not na(pl)
    p1 := p2
    p2 := p3
    p3 := pl
    i1 := i2
    i2 := i3
    i3 := bar_index

// === TRAILING STOP LINE HANDLE === //
var line trailLine = na

// === DOUBLE BOTTOM LOGIC === //
doubleBottom = not na(p1) and not na(p2) and not na(p3) and
  (math.abs(p1 - p3) / p1 * 100 <= tolerance) and
  (p2 > p1 and p2 > p3)

// === ENTRY CONDITIONS === //
isTrendOk = not useEMAFilter or (close > ema50)
isVolatilityOk = atr >= minAtr
entryCondition = doubleBottom and isTrendOk and isVolatilityOk

// === STRATEGY ENTRY + ALERT === //
if inDateRange and entryCondition and strategy.position_size == 0
    strategy.entry("Long", strategy.long)
    strategy.exit("Trailing Stop", from_entry="Long", trail_price=high, trail_offset=trail_offset)




// === EXIT ALERT === //
exitCondition = strategy.closedtrades > 0 and strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1) == bar_index
Enter fullscreen mode Exit fullscreen mode

Strategy parameters

The original address: Adaptive ATR Trailing Stop Double Bottom Breakout Quantitative Trading Strategy

Comments 1 total

  • Raxrb Kuech
    Raxrb KuechJul 15, 2025

    This strategy really said, “Why stop at a double bottom when you can trail it with style?” 😄 Love the use of adaptive ATR—it’s like giving your stop-loss a brain of its own. Smart and sneaky! Definitely going to test this out (after I convince myself not to over-optimize it to death). Great write-up!

Add comment