信号产生
各位高手,本人小白,刚刚写了策略,搞不明白不刷新就没有信号,帮我看看是不是策略写的有问题?Params Numeric lots(1);//开仓的手数 Numeric Length(5); //用于计算ATR和新高价的Bar数 Numeric Trigger(1.2); //用于计算多头进场价的驱动系数 Vars Series<Numeric> ATR; Series<Numeric> MinPoint; // 一个最小变动单位,也就是一跳 Series<Numeric> baramount; Series<Numeric> barvol; series<numeric> dayavg; series<numeric> CL;Events OnInit() { SubscribeBar(Symbol,\"3s\",BeginDateTime); array<Numeric> timepoint; timepoint = [0.1459,0.2259]; SetTriggerBarClose(timepoint); } OnBar(ArrayRef<Integer> indexs) { ATR=AvgTrueRange(Length); MinPoint = MinMove*PriceScale; CL = C; if(time==901/10000 or Time==931/10000 or Time==1001/10000 or Time==1031/10000 or Time==1101/10000 or Time==1331/10000 or Time==1401/10000 or Time==1431/10000 or Time==2101/10000 or Time==2131/10000 or Time==2201/10000 or Time==2231/10000 or Time==2301/10000 or Time==2331/10000 or Time==0001/10000 or Time==0031/10000 or Time==0101/10000 or Time==0131/10000 or Time==0201/10000) { baramount=turnover; barvol=vol; } else { baramount = baramount[1]+turnover; barvol = barvol[1]+vol; } dayavg = rollover * baramount / barvol/contractunit; data1.dayavg=dayavg; PlotNumeric(\" dayavg\",dayavg); data1.PlotNumeric(\" data1.dayavg\",data1.dayavg); } OnBaropen(ArrayRef<Integer> indexs) { If(MarketPosition <> 1 and close[1]>=dayavg[1] and High>=Close[1]+ATR[1]*Trigger And Vol > 0 ) { Buy(lots,Open); Commentary(\"多单进场\"); data0.PlotBool(\"mark\",False); data1.PlotBool(\"mark\",False); } If(MarketPosition <>-1 and close[1]<=dayavg[1] and Low<=Close[1]-ATR[1]*Trigger And Vol > 0 ) { SellShort(lots,Open); Commentary(\"空单进场\"); data0.PlotBool(\"mark\",True); data1.PlotBool(\"mark\",True); } } OnBarclose(ArrayRef<Integer> indexs) { If(MarketPosition == 1 and close[1]<=dayavg[1] and BarsSinceEntry>=1 ) { Sell(lots,Close); Commentary(\"多单平仓\"); data0.PlotBool(\"mark\",True); data1.PlotBool(\"mark\",True); }else If(Time==930/10000 or Time==1000/10000 or Time==1015/10000 or Time==1100/10000 or Time==1129/10000 or Time==1400/10000 or Time==1430/10000 or Time==1459/10000 or Time==2130/10000 or Time==2200/10000 or Time==2230/10000 or Time==2300/10000 or Time==2330/10000 or Time==2359/10000 or Time==0030/10000 or Time==0100/10000 or Time==0130/10000 or Time==0200/10000 or Time==0229/10000 ) { Sell(lots,close); data1.PlotBool(\"mark\",True); } If(MarketPosition ==-1 and close[1]>=dayavg[1] and BarsSinceEntry>=1) { BuyToCover(lots,close); Commentary(\"空单平仓\"); data0.PlotBool(\"mark\",False); data1.PlotBool(\"mark\",False); }else If(Time==930/10000 or Time==1000/10000 or Time==1015/10000 or Time==1100/10000 or Time==1129/10000 or Time==1400/10000 or Time==1430/10000 or Time==1459/10000 or Time==2130/10000 or Time==2200/10000 or Time==2230/10000 or Time==2300/10000 or Time==2330/10000 or Time==2359/10000 or Time==0030/10000 or Time==0100/10000 or Time==0130/10000 or Time==0200/10000 or Time==0229/10000 ) { BuyToCover(lots,Close); data1.PlotBool(\"mark\",False); } } 确保在K线的开盘价买入,收盘价卖出,此策略是否可以对接实盘?