我的程序定义了个上下线,突破上线,按照指定价做多,突破下线按照指定价做空。
代码如下(上下线部分略)
但是运行起来以后,发现他只开多单,根本不平仓,也不开空单。然后就提示资金已不足,后续无法开仓。请问哪里出现了问题。
我试过,如果交易指令里,不用limitr,而是以thisclose直接成交,那么程序运行就没有问题
VARIABLE:myEnterPrice=0;
IF holding!=-1 AND Low<=LowerBand
then BEGIN
IF Open<LowerBand THEN myEnterPrice=Open;
Else myEnterPrice=LowerBand;
BUYShort(1,Lots,limitr,myEnterPrice);
END
IF holding!=1 AND High>=UpperBand
then BEGIN
IF Open>UpperBand THEN myEnterPrice=Open;
Else myEnterPrice=UpperBand;
Buy(1,Lots,limitr,myEnterPrice);
END
IF HOLDING=-1 AND HIGH>=SELLSHORTBand
THEN BEGIN
IF Open>SELLSHORTBand THEN myEnterPrice=open;
ELSE myEnterPrice=SELLSHORTBand;
SELLSHORT(1,Lots,limitr,myEnterPrice);
END
IF holding=1 AND Low<=SellBand
THEN BEGIN
IF Open<SellBand THEN myEnterPrice=Open;
Else myEnterPrice=SellBand;
Sell(1,Lots,limitr,myEnterPrice);
END