这是一个利用ATR指标和收盘价来捕捉趋势突破的量化交易策略。该策略通过动态计算上下趋势线来判断趋势方向,当收盘价突破趋势线时产生交易信号。该策略同时设置止损和目标价位,并可根据波动性进行移动止损。
解决方法: 1. 引入趋势过滤或震荡指标辅助判断,避免震荡市亏损 2. 根据品种与周期特性,分别优化ATR参数 3. 优化盈亏比和移动止损逻辑,提高策略收益风险比 4. 可结合趋势识别方法改进移动止损,捕捉更多趋势利润
多时间周期有助于过滤噪音,趋势把握更稳定。突破前的量价指标验证可剔除虚假信号。仓位管理的优化可提高资金利用效率。止损与盈亏比参数的优化可改善策略收益风险比。移动止损逻辑的改进则可在控制回撤的同时获得更多趋势利润。
该策略以ATR作为波动率衡量,动态调整趋势线位置,捕捉趋势突破行情。合理设置止损与盈利目标,并采用移动止损锁定利润。参数可调,适应性强。但趋势突破策略也容易受到震荡行情的影响,需要进一步优化与改进。可通过结合多周期、筛选信号、优化仓位管理、参数寻优等方式提升策略绩效和稳定性。量化策略需要在理解策略本质的基础上,不断测试与优化,力求为初学者提供更多思路与方向。
/*backtest start: 2023-03-16 00:00:00 end: 2024-03-21 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy(title = "Claw-Pattern", overlay=true, calc_on_every_tick=true, default_qty_type= strategy.percent_of_equity,default_qty_value=10, currency="USD") //Developer: Trading Strategy Guides //Creator: Trading Strategy Guides //Date: 3/18/2024 //Description: A trend trading system strategy atr_period = input(title="ATR Period", defval=120, type=input.integer) atr_mult = input(title="ATR Multiplier", defval=2, type=input.integer) dir = input(title="Direction (Long=1, Short=-1, Both = 0)", defval=1, type=input.integer) factor = input(title="Stop Level Deviation (% Chan.)", defval=0.75, type=input.float) rr = input(title="Reward to Risk Multiplier", defval=2, type=input.integer) trail_bar_start = input(title="Trail Stop Bar Start", defval=20, type=input.integer) col_candles = input(title="Enable Colored Candles", defval=false, type=input.bool) atr_signal = atr(atr_period) lower_trend = low - atr_mult*atr_signal upper_trend = high + atr_mult*atr_signal upper_trend := upper_trend > upper_trend[1] and close < upper_trend[1] ? upper_trend[1] : upper_trend lower_trend := lower_trend < lower_trend[1] and close > lower_trend[1] ? lower_trend[1] : lower_trend upper_color = barssince(cross(close, upper_trend[1])) > barssince(cross(close, lower_trend[1])) ? color.red : na lower_color = barssince(cross(close, upper_trend[1])) > barssince(cross(close, lower_trend[1])) ? na : color.green trend_line = lower_trend plot(lower_trend, color=lower_color, title="Lower Trend Color") plot(upper_trend, color=upper_color, title="Upper Trend Color") is_buy = strategy.position_size == 0 and crossover(close, upper_trend[1]) and upper_color[1]==color.red and (dir == 1 or dir == 0) is_sell = strategy.position_size == 0 and crossover(close, lower_trend[1]) and lower_color[1]==color.green and (dir == -1 or dir == 0) if is_buy strategy.entry("Enter Long", strategy.long) else if is_sell strategy.entry("Enter Short", strategy.short)