Skip to content

Latest commit

 

History

History
190 lines (145 loc) · 10.1 KB

File metadata and controls

190 lines (145 loc) · 10.1 KB

Name

ATR融合趋势优化模型策略-ATR-Fusion-Trend-Optimization-Model-Strategy

Author

ChaoZhang

Strategy Description

IMG

[trans]

概述

本策略是一个基于ATR和Fibonacci数列加权的高级趋势跟踪系统。它通过将多个时间周期的波动率分析与Fibonacci加权平均相结合,构建了一个响应灵敏、适应性强的交易模型。该策略的核心在于通过动态权重分配,更好地捕捉市场趋势,并利用ATR实现精准的获利了结。

策略原理

策略采用多层次的技术指标组合方法:首先计算真实波动范围(TR)和买入压力(BP),然后基于Fibonacci数列时间周期(8,13,21,34,55)计算各个周期的压力比率。通过对不同周期施加不同权重(5,4,3,2,1),构建加权平均值,并进一步应用3周期SMA平滑处理。系统根据SMA与预设阈值(58.0和42.0)的交叉来触发交易信号,并利用ATR设计了四步式获利了结机制。

策略优势

  1. 多维度分析:结合多个时间周期的数据,提供更全面的市场视角
  2. 动态适应:通过ATR自适应市场波动,提高策略稳定性
  3. 智能获利:四步式获利机制可以在不同市场环境下灵活调整
  4. 风险可控:清晰的入场出场条件,降低主观判断带来的风险
  5. 系统化操作:策略逻辑明确,易于量化实现和回测验证

策略风险

  1. 参数敏感性:多个阈值和权重参数需要careful调整
  2. 滞后性风险:SMA平滑可能导致信号延迟
  3. 市场环境依赖:在震荡市场中可能产生虚假信号
  4. 参数配适:不同市场条件下参数需要重新优化 解决方案:建议进行充分的参数优化和回测,并根据不同市场阶段动态调整参数。

策略优化方向

  1. 参数自适应:开发自适应参数调整机制,提高策略适应性
  2. 市场筛选:增加市场环境识别模块,在适合的市场条件下执行交易
  3. 信号优化:引入辅助确认指标,提高信号可靠性
  4. 风控增强:增加动态止损和仓位管理模块
  5. 回撤控制:添加最大回撤限制,提高策略稳定性

总结

该策略通过整合ATR和Fibonacci加权平均技术,构建了一个全面的趋势跟踪系统。其优势在于多维度分析和动态适应能力,但也需要注意参数优化和市场环境筛选。通过持续优化和风控增强,策略有望在不同市场环境下保持稳定表现。 ||

Overview

This strategy is an advanced trend following system based on ATR and Fibonacci weighted averages. It combines volatility analysis across multiple timeframes with Fibonacci weighted averaging to create a responsive and adaptive trading model. The core strength lies in its dynamic weight allocation for better trend capture and precise profit-taking using ATR.

Strategy Principle

The strategy employs a multi-layered technical indicator approach: It first calculates True Range (TR) and Buying Pressure (BP), then computes pressure ratios based on Fibonacci sequence periods (8,13,21,34,55). Different weights (5,4,3,2,1) are applied to different periods to construct a weighted average, further smoothed by a 3-period SMA. Trading signals are triggered by SMA crossovers with preset thresholds (58.0 and 42.0), and a four-step profit-taking mechanism is designed using ATR.

Strategy Advantages

  1. Multi-dimensional analysis: Combines data from multiple timeframes for a comprehensive market perspective
  2. Dynamic adaptation: Adapts to market volatility through ATR, enhancing strategy stability
  3. Intelligent profit-taking: Four-step profit mechanism flexibly adjusts to different market conditions
  4. Controlled risk: Clear entry and exit conditions reduce subjective judgment risks
  5. Systematic operation: Clear strategy logic, easy to quantify and backtest

Strategy Risks

  1. Parameter sensitivity: Multiple thresholds and weight parameters require careful adjustment
  2. Lag risk: SMA smoothing may cause signal delays
  3. Market environment dependence: May generate false signals in ranging markets
  4. Parameter fitting: Parameters need optimization for different market conditions Solution: Recommend thorough parameter optimization and backtesting, with dynamic parameter adjustment for different market phases.

Strategy Optimization Directions

  1. Parameter adaptation: Develop adaptive parameter adjustment mechanisms
  2. Market filtering: Add market environment recognition module
  3. Signal optimization: Introduce auxiliary confirmation indicators
  4. Risk control enhancement: Add dynamic stop-loss and position management
  5. Drawdown control: Implement maximum drawdown limits

Summary

This strategy integrates ATR and Fibonacci weighted averages to build a comprehensive trend following system. Its strengths lie in multi-dimensional analysis and dynamic adaptation capabilities, while attention must be paid to parameter optimization and market environment filtering. Through continuous optimization and risk control enhancement, the strategy can maintain stable performance across different market conditions.[/trans]

Source (PineScript)

/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PresentTrading

// The Fibonacci ATR Fusion Strategy is an advanced trading methodology that uniquely integrates Fibonacci-based weighted averages with the Average True Range (ATR) to 
// identify and exploit significant market trends. Unlike traditional strategies that rely on single indicators or fixed parameters, this approach leverages multiple timeframes and 
// dynamic volatility measurements to enhance accuracy and adaptability. 

//@version=5
strategy("Fibonacci ATR Fusion - Strategy [presentTrading]", overlay=false, precision=3, commission_value= 0.1, commission_type=strategy.commission.percent, slippage= 1, currency=currency.USD, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, initial_capital=10000)

// Calculate True High and True Low
tradingDirection = input.string(title="Trading Direction", defval="Both", options=["Long", "Short", "Both"])

// Trading Condition Thresholds
long_entry_threshold = input.float(58.0, title="Long Entry Threshold")
short_entry_threshold = input.float(42.0, title="Short Entry Threshold")
long_exit_threshold = input.float(42.0, title="Long Exit Threshold")
short_exit_threshold = input.float(58.0, title="Short Exit Threshold")

// Enable or Disable 4-Step Take Profit
useTakeProfit = input.bool(false, title="Enable 4-Step Take Profit")

// Take Profit Levels (as multiples of ATR)
tp1ATR = input.float(3.0, title="Take Profit Level 1 ATR Multiplier")
tp2ATR = input.float(8.0, title="Take Profit Level 2 ATR Multiplier")
tp3ATR = input.float(14.0, title="Take Profit Level 3 ATR Multiplier")

// Take Profit Percentages
tp1_percent = input.float(12.0, title="TP Level 1 Percentage", minval=0.0, maxval=100.0)
tp2_percent = input.float(12.0, title="TP Level 2 Percentage", minval=0.0, maxval=100.0)
tp3_percent = input.float(12.0, title="TP Level 3 Percentage", minval=0.0, maxval=100.0)

true_low = math.min(low, close[1])
true_high = math.max(high, close[1])

// Calculate True Range
true_range = true_high - true_low

// Calculate BP (Buying Pressure)
bp = close - true_low

// Calculate ratios for different periods
calc_ratio(len) =>
    sum_bp = math.sum(bp, len)
    sum_tr = math.sum(true_range, len)
    100 * sum_bp / sum_tr

// Calculate weighted average of different timeframes
weighted_avg = (5 * calc_ratio(8) + 4 * calc_ratio(13) + 3 * calc_ratio(21) + 2 * calc_ratio(34) + calc_ratio(55)) / (5 + 4 + 3 + 2 + 1)
weighted_avg_sma = ta.sma(weighted_avg,3)

// Plot the indicator
plot(weighted_avg, "Fibonacci ATR", color=color.blue, linewidth=2)
plot(weighted_avg_sma, "SMA Fibonacci ATR", color=color.yellow, linewidth=2)

// Define trading conditions
longCondition = ta.crossover(weighted_avg_sma, long_entry_threshold)  // Enter long when weighted average crosses above threshold
shortCondition = ta.crossunder(weighted_avg_sma, short_entry_threshold) // Enter short when weighted average crosses below threshold
longExit = ta.crossunder(weighted_avg_sma, long_exit_threshold)
shortExit = ta.crossover(weighted_avg_sma, short_exit_threshold)


atrPeriod = 14
atrValue = ta.atr(atrPeriod)

if (tradingDirection == "Long" or tradingDirection == "Both")
    if (longCondition)
        strategy.entry("Long", strategy.long)
        // Set Take Profit levels for Long positions
        if useTakeProfit
            tpPrice1 = strategy.position_avg_price + tp1ATR * atrValue
            tpPrice2 = strategy.position_avg_price + tp2ATR * atrValue
            tpPrice3 = strategy.position_avg_price + tp3ATR * atrValue
            // Close partial positions at each Take Profit level
            strategy.exit("TP1 Long", from_entry="Long", qty_percent=tp1_percent, limit=tpPrice1)
            strategy.exit("TP2 Long", from_entry="Long", qty_percent=tp2_percent, limit=tpPrice2)
            strategy.exit("TP3 Long", from_entry="Long", qty_percent=tp3_percent, limit=tpPrice3)
    if (longExit)
        strategy.close("Long")

if (tradingDirection == "Short" or tradingDirection == "Both")
    if (shortCondition)
        strategy.entry("Short", strategy.short)
        // Set Take Profit levels for Short positions
        if useTakeProfit
            tpPrice1 = strategy.position_avg_price - tp1ATR * atrValue
            tpPrice2 = strategy.position_avg_price - tp2ATR * atrValue
            tpPrice3 = strategy.position_avg_price - tp3ATR * atrValue
            // Close partial positions at each Take Profit level
            strategy.exit("TP1 Short", from_entry="Short", qty_percent=tp1_percent, limit=tpPrice1)
            strategy.exit("TP2 Short", from_entry="Short", qty_percent=tp2_percent, limit=tpPrice2)
            strategy.exit("TP3 Short", from_entry="Short", qty_percent=tp3_percent, limit=tpPrice3)
    if (shortExit)
        strategy.close("Short")

Detail

https://www.fmz.com/strategy/473263

Last Modified

2024-11-28 17:06:21