网友回复://固定时间间隔,有信号就下单,信号闪烁情况下造成HOLDING值不稳定,故不能调用图表的HOLDING来控制仓位,必须使用后台程序化交易, 总体思路是用BARPOS和全局变量结合起来,控制是否开仓。 //序列模式运行 //t1_flag 0表示没有仓位,1表示持有多头,-1表示持有空头 //bar控制一根K线只能有一次开平仓 ss:=1; //手数 ma5:ema(c,5); buycond:=h>ma5; sellcond:=l<ma5; //平多 if extgbdata('t1_flag')>0 and sellcond and barpos>extgbdata('bar') then begin tsell(1,ss,mkt); extgbdataset('t1_flag',0); end //平空 if extgbdata('t1_flag')<0 and buycond and barpos>extgbdata('bar') then begin tsellshort(1,ss,mkt); extgbdataset('t1_flag',0); end