该策略基于干浪指标实现简单的趋势跟踪操作。当价格收盘突破上轨时做多,收盘跌破下轨时做空。属于典型的趋势追踪策略。
计算指定周期的最高价和最低价的加权移动平均线,获得上轨和下轨。
收盘价格高于上轨时,进行做多操作。
收盘价格低于下轨时,进行做空操作。
平仓信号为价格收盘反向突破上轨或下轨。
可选择策略生效的起始时间,默认为全周期。
干浪指标参数简单,容易实现。
突破上下轨形成明确的交易信号。
可灵活选择策略生效时间段。
策略逻辑简单清晰,容易理解。
回测效果良好,可与趋势市场配合使用。
作为空头策略,存在无限亏损风险。
参数不当可能导致策略频繁止损再入场。
无法有效处理盘整震荡市,容易被套。
仅基于指标,应增加过滤以避免失效。
优化参数组合,降低错误信号。
增加移动止损确保风险可控。
加入EMA等指标判断大市和入场时机。
结合交易量,避开震荡假突破。
加入时间段过滤,缩小策略生效范围。
该策略通过干浪通道完成简单的趋势跟踪,但可进一步增强指标逻辑、参数优化、风险控制等使策略更稳健。
/*backtest
start: 2022-09-10 00:00:00
end: 2023-09-16 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © starbolt
//@version=5
strategy('Gann HiLo Activator Strategy', overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=1000, process_orders_on_close=true)
len = input.int(3, 'Length', step=1, minval=1)
displace = input.int(1, 'Offset', step=1, minval=0)
from_start = input(false, 'Begin from start?')
backtest_year = input(2017, 'From Year')
backtest_month = input.int(01, 'From Month', minval=1, maxval=12, step=1)
backtest_day = input.int(01, 'From Day', minval=1, maxval=31, step=1)
start_time = from_start ? 0 : timestamp(backtest_year, backtest_month, backtest_day, 00, 00)
float hilo = na
hi = ta.sma(high, len)
lo = ta.sma(low, len)
hilo := close > hi[displace] ? 1 : close < lo[displace] ? -1 : hilo[1]
ghla = hilo == -1 ? hi[displace] : lo[displace]
color = hilo == -1 ? color.red : color.green
buyCondition = hilo == 1 and hilo[1] == -1
sellCondition = hilo == -1 and hilo[1] == 1
if buyCondition and time >= start_time
strategy.entry('Long', strategy.long)
if sellCondition and time >= start_time
strategy.entry('Short', strategy.short)
plot(ghla, color=color, style=plot.style_cross)