基于双SMA系统的趋势跟踪策略


创建日期: 2023-09-20 11:35:30 最后修改: 2023-09-20 11:35:30
复制: 1 点击次数: 401
1
关注
1138
关注者

概述

该策略仅使用两条SMA均线,其中慢速SMA用于判断趋势方向,快速SMA用于入场信号。结合K线实体颜色判定,产生长仓和短仓信号。策略追踪中期趋势,适用于高位震荡或低位震荡的行情。

策略原理

计算一快一慢两条SMA均线,以及价格通道的中线。快线周期为5,慢线周期为20。当价格通道中线上方,视为上升趋势,该阶段寻找快线上穿慢线的机会做多;当价格通道中线下方,视为下降趋势,寻找快线下穿慢线的机会做空。

此外,结合K线实体颜色判断,如果是上升趋势,要求见底K线连续大于等于2根红色实体,然后快线上穿慢线时做多;如果是下降趋势,要求见顶K线连续大于等于2根绿色实体,然后快线下穿慢线时做空。

优势分析

该策略同时利用两条SMA均线和价格通道判断趋势方向,避免被假突破误导。并加入K线实体颜色判定过滤假信号。做多做空信号同时存在,可以对冲操作。能够有效跟踪中期趋势。

参数可自定义配置长短仓条件,适应性强。回测数据显示,该策略在高位震荡和低位震荡市场中都能获得不错收益。

风险分析

该策略过于依赖均线指标,在震荡行情中存在产生过多虚假信号的可能。且仅考虑价格因素,忽略了成交量的影响。

可以适当调整SMA周期参数,或加入其他技术指标进行信号过滤。也可以引入量能指标等进行综合判断。此外,可优化仓位管理,根据市场情况调整仓位大小。

优化方向

  1. 测试不同的SMA快慢线组合,找到最优参数。

  2. 增加成交量等指标进行信号校验。

  3. 结合其他技术指标形成策略组合。

  4. 设置动态仓位,优化资金管理。

  5. 应用机器学习预测价格趋势和转折点。

  6. 优化止损策略,防止过度亏损。

总结

该策略整体思路清晰,利用双SMA系统判断趋势较为常见。但仅靠均线系统容易产生误信号,需要引入其他技术指标进行优化。如果能够引入更多定性和定量指标进行验证,该策略效果会更好。总体来说,其提供了一种简单可靠的趋势跟踪策略模板。

策略源码
/*backtest
start: 2023-08-20 00:00:00
end: 2023-09-19 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Noro's Trend SMA Strategy v1.4", shorttitle = "Trend SMA str 1.4", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)

needlong = input(true, "long")
needshort = input(true, "short")
usefastsma = input(true, "Use fast SMA")
fastlen = input(5, defval = 5, minval = 1, maxval = 50, title = "fast SMA Period")
slowlen = input(20, defval = 20, minval = 2, maxval = 200, title = "slow SMA Period")
bars = input(2, defval = 2, minval = 0, maxval = 3, title = "Bars Q")

fastsma = ema(close, fastlen)
slowsma = ema(close, slowlen)

//PriceChannel
src = ohlc4
lasthigh = highest(src, slowlen)
lastlow = lowest(src, slowlen)
center = (lasthigh + lastlow) / 2

trend = low > center ? 1 : high < center ? -1 : trend[1]

bar = close > open ? 1 : close < open ? -1 : 0
redbars = bars == 0 ? 1 : bars == 1 and bar == -1 ? 1 : bars == 2 and bar == -1 and bar[1] == -1 ? 1 : bars == 3 and bar == -1 and bar[1] == -1 and bar[2] == -1 ? 1 : 0
greenbars = bars == 0 ? 1 : bars == 1 and bar == 1 ? 1 : bars == 2 and bar == 1 and bar[1] == 1 ? 1 : bars == 3 and bar == 1 and bar[1] == 1 and bar[2] == 1 ? 1 : 0

up = trend == 1 and (low < fastsma or usefastsma == false) and redbars == 1 ? 1 : 0
dn = trend == -1 and (high > fastsma or usefastsma == false) and greenbars == 1 ? 1 : 0

colorfastsma = usefastsma == true ? red : na
plot(fastsma, color = colorfastsma, title = "Fast SMA")
plot(center, color = blue, title = "Price Channel")

longCondition = up == 1
if (longCondition)
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na)

shortCondition = dn == 1
if (shortCondition)
    strategy.entry("Short", strategy.short, needshort == false ? 0 : na)
更多内容