多重均线多头趋势策略是一个基于多条不同周期的指数移动平均线(EMA)构建判断的趋势跟踪策略。它会在价格突破10日EMA并且其他较长周期的EMA线呈多头排列时做多;然后使用8%的尾随止损来锁定利润。
该策略使用了10日、20日、50日、100日、150日和200日六条不同周期的EMA线。这些EMA线被用来判断市场目前所处的周期阶段。当短期EMA线(如10日线)上穿较长周期的EMA线(如20日、50日线)时,被视为市场步入多头趋势的markup阶段。
具体来说,当满足以下几个条件时,策略会开仓做多:
做多开仓后,策略会使用8%的尾随止损来锁定利润。也就是说,只要股票价格没有回落超过购买价格的8%,那么就会继续持有该头寸。一旦出现超过8%的回撤,就会停止损失。
总的来说,该策略的核心思路是:使用EMA多重筛选条件判断进入多头趋势后,尾随止损来锁定利润。
这种多重均线多头趋势策略具有以下几点主要优势:
该策略也存在一些风险需要注意:
针对以上风险,我们可以通过适当调整EMA周期参数或者引入其他指标作为辅助判断来进行优化和改进。
考虑到该策略的特点,未来可以从以下几个方面进行优化:
多重均线多头趋势策略整体来说是一个较为稳健可靠的趋势跟踪策略。它同时兼顾了趋势判断和风险控制。通过参数调优和算法优化还具有很大的改进空间。总的来说这是一个值得尝试使用和研究的有效策略。
/*backtest
start: 2023-01-15 00:00:00
end: 2024-01-21 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy('SirSeff\'s EMA Rainbow', overlay=true)
// Testing Start dates
testStartYear = input(2000, 'Backtest Start Year')
testStartMonth = input(1, 'Backtest Start Month')
testStartDay = input(1, 'Backtest Start Day')
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)
//Stop date if you want to use a specific range of dates
testStopYear = input(2100, 'Backtest Stop Year')
testStopMonth = input(12, 'Backtest Stop Month')
testStopDay = input(30, 'Backtest Stop Day')
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)
testPeriod() =>
time >= testPeriodStart and time <= testPeriodStop ? true : false
// Component Code Stop
//TSP
trailStop = input.float(title='Long Trailing Stop (%)', minval=0.0, step=0.1, defval=8) * 0.01
longStopPrice = 0.0
longStopPrice := if strategy.position_size > 0
stopValue = close * (1 - trailStop)
math.max(stopValue, longStopPrice[1])
else
0
//PLOTS
plot(series=strategy.position_size > 0 ? longStopPrice : na, color=color.new(color.red, 0), style=plot.style_linebr, linewidth=1, title='Long Trail Stop', offset=1, title='Long Trail Stop')
plot(ta.ema(close, 20))
plot(ta.ema(close, 50))
plot(ta.ema(close, 100))
plot(ta.ema(close, 150))
plot(ta.ema(close, 200))
//OPEN
longCondition = ta.ema(close, 10) > ta.ema(close, 20) and ta.ema(close, 20) > ta.ema(close, 50) and ta.ema(close, 100) > ta.ema(close, 150) and ta.ema(close, 150) > ta.ema(close, 200)
if longCondition and ta.crossover(close,ta.ema(close,10)) and testPeriod()
strategy.entry("BUY1", strategy.long)
if longCondition and ta.crossover(ta.ema(close,10),ta.ema(close,20)) and testPeriod()
strategy.entry("BUY2'", strategy.long)
//CLOSE @ TSL
if strategy.position_size > 0 and testPeriod()
strategy.exit(id='TSP', stop=longStopPrice)