Multi-Indicator Breakout Trend Following Strategy

ATR SL N1 N2 波动率过滤 风险管理 多周期 趋势跟踪 海龟交易
Created on: 2025-07-03 10:14:35 Modified on: 2025-07-03 10:14:35
Copy: 6 Number of hits: 265
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Multi-Indicator Breakout Trend Following Strategy  Multi-Indicator Breakout Trend Following Strategy

Overview

The Multi-Indicator Breakout Trend Following Strategy is a quantitative trading approach based on the classic Turtle Trading system, designed to capture strong market trends through multi-period breakout signals. The core of this strategy lies in utilizing price breakouts across different time periods as entry and exit signals, while incorporating ATR (Average True Range) for risk control and position sizing. This strategy can function both as an indicator to identify market breakout signals and as a complete automated trading system. Its strength lies in systematically capturing trending opportunities while enhancing capital efficiency through strict risk management.

Strategy Principles

The fundamental principle of this strategy is to identify potential trend movements by recognizing when prices break through historical highs or lows. The specific implementation logic is as follows:

  1. Entry Mechanism: The strategy uses the highest and lowest prices over the N1 period (default 20 periods) as breakout references. When the price breaks above the highest price of the previous N1 periods, a long entry signal is generated; when the price breaks below the lowest price of the previous N1 periods, a short entry signal is generated.

  2. Exit Mechanism: The strategy employs a dual exit mechanism:

    • Stop Loss Exit: Dynamic stop loss levels are set based on ATR, defaulting to the entry price minus (for longs) or plus (for shorts) 2 times the ATR value.
    • Trend Reversal Exit: When the price falls below the lowest price of the N2 period (default 10 periods), long positions are closed; when the price breaks above the highest price of the N2 period, short positions are closed.
  3. Position Management: The strategy calculates trading unit size based on volatility (ATR) and risk ratio, ensuring that each trade’s risk is controlled at a fixed percentage (default 1%) of account capital. The calculation formula is:

    Trading Units = Risk Amount / (ATR * Value Per Point)
    

    where Risk Amount equals the initial capital multiplied by the risk percentage.

  4. Trade Execution: The strategy only executes new entry signals when there are no existing positions, avoiding repeated entries, while recording the entry price for calculating stop loss positions.

Strategy Advantages

  1. Trend Following Capability: The strategy is focused on capturing major trends by identifying potential trend starting points through breakout signals, effectively utilizing trending market movements.

  2. Dynamic Risk Control: Stop loss positions are calculated using ATR, dynamically adjusting the stop loss distance based on actual market volatility. This approach avoids both the frequent stops caused by fixed stops being too close and the excessive losses from stops being too far.

  3. Adaptive Position Sizing: Position size is dynamically adjusted based on market volatility and account risk ratio, automatically reducing positions in highly volatile markets and appropriately increasing positions in low volatility markets, achieving balanced control of risk exposure.

  4. Parameter Adjustability: The strategy provides interfaces for adjusting multiple key parameters (N1, N2, ATR period, risk ratio, etc.), allowing users to optimize based on different market environments and personal risk preferences.

  5. Systematic Trading: Fully systematized trading rules eliminate emotional interference, strictly following preset entry, exit, and capital management rules, improving trading discipline.

Strategy Risks

  1. Poor Performance in Ranging Markets: As a trend following strategy, it tends to generate frequent false breakout signals in sideways, ranging markets, leading to consecutive stop losses. A solution could be to add volatility filtering conditions, considering entry only when volatility exceeds a certain threshold.

  2. Slippage and Commission Impact: In high-frequency trading or markets with insufficient liquidity, slippage and commissions may significantly affect strategy performance. This issue can be mitigated by reducing trading frequency or adding signal confirmation mechanisms.

  3. Parameter Sensitivity: Strategy performance is relatively sensitive to N1 and N2 parameter settings, with optimal parameters potentially varying greatly across different markets and timeframes. It is recommended to find robust parameter combinations through historical backtesting, avoiding curve-fitting from excessive optimization.

  4. Gap Risk: In price gaps caused by sudden major events, stop loss orders may not execute at the expected price, causing losses beyond expectations. Consider adding maximum loss limits or introducing volatility adjustment factors.

  5. Capital Management Risk: Despite the strategy’s risk control mechanisms, consecutive stop losses in extreme market conditions may still lead to significant drawdowns in the capital curve. It is advisable to set limits on the maximum number of consecutive losses or introduce overall risk exposure controls.

Optimization Directions

  1. Multi-Timeframe Confirmation: Introduce longer period trend confirmation mechanisms, considering entry only when trends across multiple timeframes are consistent, improving signal quality. For example, add conditions to check whether the daily trend direction is consistent with the current trading period’s trend direction.

  2. Volatility Filtering: Introduce volatility filtering conditions, executing trade signals only when market volatility is within a reasonable range, avoiding entry in overly calm or excessively volatile markets. Relative ATR values (such as ATR/price ratio) can be used as filtering indicators.

  3. Signal Confirmation Mechanism: Add breakout confirmation mechanisms, such as requiring the price to maintain a certain time or amplitude after breakout before confirming signal validity, reducing losses from false breakouts.

  4. Dynamic Parameter Adjustment: Dynamically adjust N1 and N2 parameters based on market conditions, using different parameter combinations in different volatility environments, improving the strategy’s adaptability to market environments.

  5. Incorporate Trend Strength Assessment: Combine trend strength indicators (such as ADX, linear regression slope, etc.) to evaluate current trend strength, considering entry only when trend strength reaches a certain threshold, improving the accuracy of trend capture.

  6. Optimize Stop Loss Mechanism: Consider introducing trailing stops or support/resistance-based stop methods, giving trends more room to develop while maintaining risk control functionality.

Summary

The Multi-Indicator Breakout Trend Following Strategy is a systematic trading approach that combines classic Turtle Trading concepts with modern risk management techniques. By determining trend direction through multi-period price breakouts and implementing dynamic stop losses and position control with ATR, this strategy can effectively capture significant trending opportunities in the market.

The core advantages of this strategy lie in its systematic trading rules and strict risk control, avoiding emotional interference while providing high flexibility through parameter adjustments. However, as a trend following strategy, its performance may be poor in ranging markets, requiring users to understand its applicable scenarios and perform appropriate parameter optimization.

By introducing optimization directions such as multi-timeframe confirmation, volatility filtering, and signal confirmation mechanisms, this strategy has the potential to further improve signal quality and stability, adapting to more diverse market environments. Ultimately, the Multi-Indicator Breakout Trend Following Strategy provides traders with a reliable, systematic method to capture market trends while controlling risk, achieving long-term stable trading performance.

Strategy source code
/*backtest
start: 2024-07-03 00:00:00
end: 2025-07-01 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"DOGE_USDT"}]
*/

//@version=5
strategy("Turtle Trading Strategy (Simplified)", overlay=true, initial_capital=10000, default_qty_type=strategy.cash, default_qty_value=1000, commission_type=strategy.commission.cash_per_order, commission_value=1)

// --- Strategy Inputs ---
n1_entry_period = input.int(20, title="Entry Lookback Period (N1)", minval=1)
n2_exit_period = input.int(10, title="Exit Lookback Period (N2)", minval=1)
atr_period = input.int(20, title="ATR Period", minval=1)
atr_multiplier = input.float(2.0, title="ATR Stop Multiplier", minval=0.1)
risk_per_trade_percent = input.float(1.0, title="Risk Per Trade (%)", minval=0.1, maxval=10.0)

// --- Calculate Channels ---
highest_high_n1 = ta.highest(high, n1_entry_period)
lowest_low_n1 = ta.lowest(low, n1_entry_period)

highest_high_n2 = ta.highest(high, n2_exit_period)
lowest_low_n2 = ta.lowest(low, n2_exit_period)

// --- Calculate ATR (Average True Range) ---
atr_value = ta.atr(atr_period)

// --- Position Sizing (Simplified) ---
// This aims to calculate units based on a fixed percentage risk per trade.
// 1 Unit = 1 ATR worth of movement. Risk 1% of equity per trade.
risk_amount = strategy.initial_capital * (risk_per_trade_percent / 100)
dollar_per_point = syminfo.mintick // Or your instrument's specific dollar per point value
unit_size = atr_value * dollar_per_point > 0 ? math.round(risk_amount / (atr_value * dollar_per_point)) : 0

// Ensure unit_size is at least 1 if risk allows, and cap it for realism
if unit_size == 0 and risk_amount > 0
    unit_size := 1 // Minimum 1 unit if risk allows any trade
if unit_size > 10000 // Cap unit size to prevent excessively large positions in backtesting
    unit_size := 10000

// --- Entry Logic ---
long_condition = ta.crossover(close, highest_high_n1[1]) // Break above previous N1 high
short_condition = ta.crossunder(close, lowest_low_n1[1]) // Break below previous N1 low

// Variables to store entry information only for the *current* bar
var float current_entry_price = na
var int current_entry_type = 0 // 1 for long, -1 for short, 0 for no entry

if long_condition and strategy.opentrades == 0 // Only enter if no open positions
    strategy.entry("Long", strategy.long, qty=unit_size, comment="Turtle Long Entry")
    // Store entry details for the current bar
    current_entry_price := close // Or strategy.opentrades[0].entry_price if you prefer but close on entry bar is often same
    current_entry_type := 1

if short_condition and strategy.opentrades == 0 // Only enter if no open positions
    strategy.entry("Short", strategy.short, qty=unit_size, comment="Turtle Short Entry")
    // Store entry details for the current bar
    current_entry_price := close // Or strategy.opentrades[0].entry_price
    current_entry_type := -1

// --- Exit Logic ---

// Declare persistent variables to store stop prices
var float long_stop_price = na
var float short_stop_price = na

// Calculate and store stop price on the bar *after* an entry
if current_entry_type[1] == 1 // If a long entry occurred on the previous bar
    long_stop_price := current_entry_price[1] - (atr_value[1] * atr_multiplier) // Use values from previous bar
    short_stop_price := na // Reset short stop

if current_entry_type[1] == -1 // If a short entry occurred on the previous bar
    short_stop_price := current_entry_price[1] + (atr_value[1] * atr_multiplier) // Use values from previous bar
    long_stop_price := na // Reset long stop

// Stop Loss for Long Positions
if strategy.position_size > 0 // We have a long position
    strategy.exit("Long Exit SL", from_entry="Long", stop=long_stop_price, comment="Long Stop Loss")

// Stop Loss for Short Positions
if strategy.position_size < 0 // We have a short position
    strategy.exit("Short Exit SL", from_entry="Short", stop=short_stop_price, comment="Short Stop Loss")

// N2 Exit for Long Positions
if strategy.position_size > 0 and ta.crossunder(close, lowest_low_n2[1])
    strategy.close("Long", comment="Turtle Long N2 Exit")

// N2 Exit for Short Positions
if strategy.position_size < 0 and ta.crossover(close, highest_high_n2[1])
    strategy.close("Short", comment="Turtle Short N2 Exit")

// --- Plotting for Visualization ---
plot(highest_high_n1, "N1 High", color=color.green, linewidth=2, style=plot.style_linebr)
plot(lowest_low_n1, "N1 Low", color=color.red, linewidth=2, style=plot.style_linebr)
plot(highest_high_n2, "N2 High (Exit)", color=color.blue, linewidth=1, style=plot.style_linebr)
plot(lowest_low_n2, "N2 Low (Exit)", color=color.orange, linewidth=1, style=plot.style_linebr)