Stochastics Oscillator指标设置为:5,3,3 等级 : 15, 85, 30, 70
回测测试
/*backtest start: 2021-12-01 00:00:00 end: 2022-05-30 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}] args: [["v_input_int_1",15],["v_input_int_4",9],["v_input_int_5",2],["v_input_int_6",2],["ContractType","i2209",360008]] */ //@version=5 indicator('Nik Stoch') lookback_period = input.int(15, minval=1, title="回看周期") m1 = input.int(3, minval=1) m2 = input.int(3, minval=1) k = ta.sma(ta.stoch(close, high, low, lookback_period), m1) d = ta.sma(k, m2) //plot(k) //plot(d, color=color.red) h0 = hline(15) h1 = hline(85) h2 = hline(50) h3 = hline(30) h4 = hline(70) fill(h0, h1, color=color.new(color.purple, 95)) /////stoch fast lookback_period1 = input.int(9, minval=1, title="回看周期1") m3 = input.int(2, minval=1) m4 = input.int(2, minval=1) k1 = ta.sma(ta.stoch(close, high, low, lookback_period1), m3) d1 = ta.sma(k1, m4) plot(k1, color=color.new(color.aqua, 0)) plot(d1, color=color.new(color.red, 0)) if k1[1] < d1[1] and k1 > d1 strategy.entry("Enter Short", strategy.short) else if k1[1] > d1[1] and k1 < d1 strategy.entry("Enter Long", strategy.long)