使用Kijun-Sen和EMA交叉策略

Author: 雨幕(youquant), Date: 2022-05-30 11:27:23
Tags: EMAKijun-Sen

在这个脚本中,我使用了来自Ichimoku Cloud和Moving Average的Kijun sen。

Kijun sen是Ichimoku云的基线或过去26个时期的中点价格。移动平均线是指在给定范围内不断更新的平均价格。在这个脚本中,我使用了标准的Kijun sen设置和移动平均值55长度。 当两条线交叉时,您将收到红色或绿色信号。自己试试这个指标,看看它为什么有用。

特别感谢@norok和@happyCloud1537教我! 这将从我这边带来更多的脚本,因为我真的很喜欢编码和交易。

回测测试

img

img

img


/*backtest
start: 2022-01-01 00:00:00
end: 2022-05-29 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
args: [["v_input_int_1",6],["v_input_int_2",5],["ContractType","rb2210",360008]]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Glenn234

//@version=5
indicator("Playing the cross", shorttitle="PtC", overlay=true)

// Ichimoku code - Kijun-Sen
basePeriods = input.int(6, minval=1, title="Kijun-Sen周期")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))

KijunSen = donchian(basePeriods)
plot(KijunSen, color=color.green, title="Kijun-Sen")


// Moving Average Exponential code
len = input.int(5, minval=1, title="EMA周期")
src = input(close, title="数据源")

MovingAverage = ta.ema(src, len)
plot(MovingAverage, title="EMA", color=color.red)


// Cross code
Up = MovingAverage > KijunSen and MovingAverage[1] < KijunSen[1]
Down = MovingAverage < KijunSen and MovingAverage[1] > KijunSen[1]

bgcolor(Up ? color.new(color.green, 60) : na, title="Up Cross")
bgcolor(Down ? color.new(color.red, 60) : na, title="Down Cross")

if Down
    strategy.entry("Enter Long", strategy.long)
else if Up
    strategy.entry("Enter Short", strategy.short)


相关内容

更多内容