本策略结合多种不同参数设置的EMA均线以及EOM量能指标,实现多时间周期的趋势判断,构建长线和短线共同判断的交易策略。该策略旨在利用不同周期均线的多时间周期共振,发掘更长效的趋势走势。
该策略使用4组不同周期的参数EMA均线,分别是13周期、21周期、50周期和180周期的EMA。这4组EMA均线构建了多个时间维度,用于判断价格趋势和发掘更长效的趋势模式。
策略使用EOM量能指标来确认趋势。EOM指标结合了交易量和价格波动幅度,可以有效判断买卖力道。策略判断EOM大于0时为多头市场,EOM小于0时为空头市场。
策略设置两个选项,选项1是当短期EMA站上长期EMA时做多,短期EMA站下长期EMA时平仓。选项2是当短期EMA上穿中期EMA时做多,短期EMA下穿中期EMA时平仓。两个选项可以更全面判断趋势的确认。
本策略整合多时间周期EMA判断和量能指标过滤,实现了趋势跟踪和 Noise去除。优化空间还很大,通过测试不同参数组合和加入更多指标可以进一步提高策略稳定性。同时,采用动态止损和仓位管理也可以大幅优化策略表现。
/*backtest
start: 2022-10-02 00:00:00
end: 2023-10-08 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/
// © SoftKill21
//@version=4
strategy("4x ema + volume", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )
//ema x 4
ema1l=input(13)
ema2l=input(21)
ema3l=input(50)
ema4l=input(180)
ema1=ema(close,ema1l)
ema2=ema(close,ema2l)
ema3=ema(close,ema3l)
ema4=ema(close,ema4l)
long1 = close > ema1 and ema1 > ema2 and ema2> ema3 and ema3 > ema4
long2 = crossover(ema1,ema2) and crossover(ema1,ema3)
short1 = close < ema1 and ema1 < ema2 and ema2< ema3 and ema3 < ema4
short2= crossunder(ema1,ema2) and crossunder(ema1,ema3)
//eom
length = input(14, minval=1)
div = input(10000, title="Divisor", minval=1)
eom = sma(div * change(hl2) * (high - low) / volume, length)
option1=input(true)
option2=input(false)
if(option1)
strategy.entry("long",1,when=long1 and eom>0)
strategy.close("long",when=short1 and eom<0)
if(option2)
strategy.entry("long",1,when=long2 and eom>0)
strategy.close("long",when=short2 and eom<0)