该策略是基于Renko蜡烛图的移动平均线交叉策略。它使用TEMA指标构建交叉信号,并结合长期均线进行过滤,旨在识别Renko蜡烛图上的趋势,发出买入和卖出信号。
该策略主要的信号来源是短期TEMA指标和SMA指标的金叉死叉。具体逻辑是:
当短期TEMA上穿短期SMA时,做多;当短期TEMA下穿短期SMA时,平仓。
此外,该策略还设置了两个可选参数avg_protection和gain_protection,用于调节进场和止损逻辑:
avg_protection>0时,只有当close价格低于当前持仓均价时才会买入,这样可以降低持仓成本;
gain_protection>0时,只有当close价格超过入场价一定百分比时才会卖出止盈,从而锁定盈利。
最后,策略还使用一条长期SMMA指标作为趋势过滤器。只有当close价格低于SMMA时,才会发出做多信号。
该策略主要具有以下优势:
该策略也存在一些风险:
针对这些风险,可以通过适当调整参数,设定止损位置等方式进行规避。
该策略主要可以从以下几个方面进行优化:
该策略整体来说是一个基础简单但实用性很强的移动均线交叉策略。它主要依靠Renko K线优异的去噪效果以及TEMA指标的高灵敏性产生信号。同时,长短期均线的配合也强化了它的趋势跟随能力。通过参数调节和适当优化,该策略可以成为量化交易的一个有效选择。
/*backtest
start: 2023-01-17 00:00:00
end: 2024-01-23 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("TEMA Cross", overlay = true)
tema(src, len) =>
3*ema(src, len) - 3*ema(ema(src, len), len) + ema(ema(ema(src, len),len),len)
smma(src, len) =>
sa = 0.0
sa := na(sa[1]) ? sma(src, len) : (sa[1] * (len - 1) + src) / len
sa
temaLength = input(5)
smaLength = input(3)
smmaLength = input(30)
tema1 = tema(close, temaLength)
sma1 = sma(tema1, smaLength)
smma1 = smma(close,smmaLength)
plot(tema1, color = green, title = "TEMA")
plot(sma1, color = orange, title = "SMA")
plot(smma1, color = red, title = "SMMA")
minGainPercent = input(2)
gainMultiplier = minGainPercent * 0.01 + 1
avg_protection = input(1)
gain_protection = input(1)
longCondition = crossover(tema1, sma1) and tema1 < smma1
shortCondition = crossunder(tema1, sma1)
strategy.entry("Buy", strategy.long, when = longCondition and (avg_protection >= 1 ? (na(strategy.position_avg_price) ? true : close <= strategy.position_avg_price) : true))
strategy.close_all(when = shortCondition and (gain_protection >=1 ? (close >= gainMultiplier * strategy.position_avg_price) : true))