该策略利用9和20个周期的指数移动平均值,在类似于Ichimoku云的区域之间创建彩色云。该策略在交易日结束前关闭所有交易。进入是指价格在绿色(20均线以上9均线)云或红色(20均线以下9均线)云上方收盘。退出是指价格对9均线收盘或交易日结束时。在不同的日内时间框架上运行策略 测试将显示给定符号的最佳时间框架。例如,我发现在30分钟的时间范围内,某个品种在这种策略会返回最好的结果。
回测测试
/*backtest
start: 2022-02-22 00:00:00
end: 2022-05-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
args: [["v_input_1",4],["v_input_2",16],["ContractType","i888",360008]]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rwestbrookjr
//@version=5
strategy("EMA Cloud Intraday Strategy", overlay=true, margin_long=100, margin_short=100, process_orders_on_close=true)
i_trdQty = input.int(1, "下单量", minval = 1)
fastLen = input(title = "EMA快线周期", defval = 7)
slowLen = input(title = "EMA慢线周期", defval = 20)
fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)
fema = plot(fastEMA, title = "FastEMA", color = color.green, linewidth = 1, style = plot.style_line)
sema = plot(slowEMA, title = "SlowEMA", color = color.red, linewidth = 1, style = plot.style_line)
fill(fema, sema, color = fastEMA > slowEMA ? color.new(#417505, 50) : color.new(#890101, 50), title = "Cloud")
longCondition = (close > fastEMA and fastEMA > slowEMA)
if (longCondition)
strategy.entry("Long_Entry", strategy.long)
longExit = close[1] < fastEMA
if (longExit)
strategy.close("Long_Entry",when=longExit)
//strategy.exit("exit", "My Long Entry Id", trail_points=1.5, trail_offset=0)
shortCondition = (close < fastEMA and fastEMA < slowEMA)
if (shortCondition)
strategy.entry("Short_Entry", strategy.short)
shortExit = close[1] > fastEMA
if (shortExit)
strategy.close("Short_Entry",when=shortExit)
//strategy.exit("exit", "My Short Entry Id", trail_points=1.5, trail_offset=0)