本策略名为“基于TSI指标和Hull移动平均线的量化交易策略”,主要思想是结合TSI指标和Hull移动平均线来识别股票、数字货币或外汇中的趋势,并在趋势开始时产生交易信号。
该策略使用TSI指标判断价格趋势和动量。TSI指标基于价格变化率的双重平滑移动平均线。当TSI值上穿其自身的移动平均线时产生买入信号,下穿时产生卖出信号。
该策略还使用Hull移动平均线判断价格趋势。Hull移动平均线通过双重加权移动平均线构建,可有效过滤市场噪音。当快线上穿慢线时判断为上涨趋势,下穿时判断为下跌趋势。
在TSI指标发出信号的同时,如果Hull移动平均线也确认了相同方向的趋势,则产生相应的交易信号。此外,策略还检查K线实体方向以确认趋势。只有当指标信号、Hull信号和K线实体方向一致时,才会发出交易信号。
该策略结合了趋势、动量和平均线多种指标,可以有效识别市场趋势的开始,避免产生大量假信号。双重平滑移动平均线也可以过滤掉部分噪音。
相比单一指标,该策略通过组合多个指标过滤信号,可以大大提高信号质量。多个确认条件也使得策略在产生信号时具有极强的确定性。
该策略虽然可以有效识别趋势开始,但是在市场震荡时会产生一定的错误信号和过度交易。此外,参数设置不当也可能导致不必要的平仓。
为降低风险,可以适当调整 Hull 移动平均线周期或 TSI 参数,也可以加入止损来控制损失。在优化过程中需要关注信噪比以获得最佳参数。
该策略可以从以下几个方面进行优化:
本策略结合 TSI 指标和 Hull 移动平均线,在确定市场趋势后产生交易信号。策略具有较高的定时性和信号质量。通过参数优化和策略组合,可以大幅提高盈利能力并降低风险。该策略适合识别中长线趋势,特别是在数字货币和外汇市场中具有广阔的应用前景。
/*backtest start: 2022-12-11 00:00:00 end: 2023-12-17 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=2 strategy("TSI/HullMA/VWMA strategy", shorttitle="TSI/HullMA/VWMA", overlay=true, default_qty_type=strategy.percent_of_equity, max_bars_back=420, default_qty_value=100, calc_on_order_fills=true, calc_on_every_tick=true, pyramiding=0) TP = input(defval=200.00, title="TargetPoint in $", type=float, step=1) SL = input(defval=-2000.00, title="StopLoss in $", type=float, step=1) signal = input(title="Signal Length", defval=6) keh=input(title="HullMA cross",defval=2) a=input(title="VWMA",defval=2) long=35,short=35,linebuy=4,linesell=-4,ot=1,p=ohlc4[0] double_smooth(src, long, short) => fist_smooth = ema(src, long) ema(fist_smooth, short) pc = change(p) rvwma=vwma(p,round(a)) rvwma2=vwma(p,round(a*2)) n2ma=2*wma(p,round(keh/2)) nma=wma(p,keh) diff=n2ma-nma sqn=round(sqrt(keh)) n2ma1=2*wma(p[1],round(keh/2)) nma1=wma(p[1],keh) diff1=n2ma1-nma1 sqn1=round(sqrt(keh)) n1=wma(diff,sqn) n2=wma(diff1,sqn) hullbuy=n1>n2 and n1>n2[1] and rvwma>rvwma2 hullsell=n1<n2 and n1<n2[1] and rvwma<rvwma2 candlebuy=ohlc4[0]>ohlc4[1] and ohlc4[0]>ohlc4[2] and ohlc4[0]>ohlc4[3] candlesell=ohlc4[0]<ohlc4[1] and ohlc4[0]<ohlc4[2] and ohlc4[0]<ohlc4[3] double_smoothed_pc = double_smooth(pc, long, short) double_smoothed_abs_pc = double_smooth(abs(pc), long, short) tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc) strategy.entry("buy", true, na, when = tsi_value>ema(tsi_value, signal) and candlebuy and hullbuy) strategy.entry("sell", false, na, when = tsi_value<ema(tsi_value, signal) and candlesell and hullsell) strategy.close_all(when = strategy.openprofit>TP or strategy.openprofit<SL)