同一根K线开盘价和收盘价格方向相反的交易信号,不能发生交易
老师,我使用前一根K线出现交易信号后,新K线开盘价实施交易,当这个跟K线在收盘价格发生信号相反的信号,下根K线不能交易,代码如下,图片是橡胶2309的截图,谢谢指导。//------------------------------------------------------------------------// 简称: opentrade// 名称: // 类别: 公式应用// 类型: 用户应用// 输出: Void//------------------------------------------------------------------------Params //此处添加参数 Numeric n(10020);Vars //此处添加变量 series<Numeric> barslastcrossup; Bool crossup; series<Numeric> barslastcrossbelow; Bool crossbelow;Events OnBar(ArrayRef<Integer> indexs) { crossup = (c>n and c[1]<=n and marketposition<>1); barslastcrossup = nthcon(crossup,1); if(barslastcrossup == 1 and marketposition<>1) { buy(1,open); } crossbelow = (c<n and c[1]>=n and marketposition<>-1); barslastcrossbelow = nthcon(crossbelow,1); if(barslastcrossbelow == 1 and marketposition<>-1) { Sell(1,open); } PlotAuto(line,n,n,Yellow,Enum_Line,enum_solid,Enum_3Pix); Commentary(contracts=+text(currentcontracts)); PlotAuto(contracts,text(CurrentContracts),H*1.003,white); if(c<n and c[1]>=n) { PlotAuto(下穿,下穿,L*1.005); } if(c>n and c[1]<=n) { PlotAuto(上穿,上穿,L*0.995); } }