Ichimoku云平滑振荡策略

Author: 雨幕(youquant), Date: 2022-06-06 10:22:05
Tags: EMA

Ichimoku云是跟踪趋势的有力指标。通过对其进行平滑处理并将其放在单独的图表中,可以轻松识别信号,而不会干扰显示。粗线表示信号:绿色表示买入信号,红色表示卖出信号。灰色表示可能的方向变化和缺乏趋势。较细的线是云的宽度,可用于进一步确定方向。

回测测试

img

img

img


/*backtest
start: 2021-12-01 00:00:00
end: 2022-04-06 23:59:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
args: [["v_input_1",6],["v_input_2",6],["v_input_3",12],["v_input_4",12],["v_input_5",12],["ContractType","i888",360008]]
*/

//@version=4

study(title="Ichimoku Cloud Smooth Oscillator")
conversionPeriods = input(9, minval=1, title="转换行周期"),
basePeriods = input(26, minval=1, title="基础线周期")
laggingSpan2Periods = input(52, minval=1, title="滞后2周期"),
pivotPeriods = input(52, minval=1, title="枢轴点周期"),
displacement = input(26, minval=1, title="位移周期")

//T3 constants
b = 0.7
c1 = -b*b*b
c2 = 3*b*b+3*b*b*b
c3 = -6*b*b-3*b-3*b*b*b
c4 = 1+3*b+b*b*b+3*b*b
//T3 constants end

t3n(source,len) => c1 * ema(ema(ema(ema(ema(ema(source, len), len), len), len), len), len) + c2 * ema(ema(ema(ema(ema(source, len), len), len), len), len) + c3 * ema(ema(ema(ema(source, len), len), len), len) + c4 * ema(ema(ema(source, len), len), len)

conversionLine = t3n(close,conversionPeriods)
baseLine = t3n(close,basePeriods)
leadLine1 = avg(conversionLine, baseLine)[displacement]
leadLine2 = t3n(close,laggingSpan2Periods)[displacement]
middleLine = avg(leadLine1, leadLine2)
cloudHeight = leadLine1-leadLine2
conversionDistance = conversionLine-middleLine

var conversionCloudDistance = 0.0

if conversionDistance > 1/2*abs(cloudHeight) or conversionDistance < -1/2*abs(cloudHeight)
    conversionCloudDistance := conversionDistance - abs(cloudHeight) / 2
else
    conversionCloudDistance := 0

var conversionColor = color.green
if conversionCloudDistance > 0
    conversionColor := color.green
else if conversionCloudDistance < 0
    conversionColor := color.red
else
    conversionColor := color.gray
    
cloudColor = cloudHeight > 0 ? color.green : color.red
p1 = plot(cloudHeight, color=cloudColor)
p2 = plot(conversionCloudDistance, color=conversionColor, linewidth = 4)
plot(0, color=color.black)




if conversionCloudDistance>0
    strategy.entry("Enter Long", strategy.long)
else if conversionCloudDistance<0
    strategy.entry("Enter Short", strategy.short)



相关内容

更多内容