Ichimoku云是跟踪趋势的有力指标。通过对其进行平滑处理并将其放在单独的图表中,可以轻松识别信号,而不会干扰显示。粗线表示信号:绿色表示买入信号,红色表示卖出信号。灰色表示可能的方向变化和缺乏趋势。较细的线是云的宽度,可用于进一步确定方向。
回测测试
/*backtest start: 2022-01-01 00:00:00 end: 2022-06-01 00:00:00 period: 5m basePeriod: 1m exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}] args: [["ContractType","i2209",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)template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6