不论有没有持仓,都该有 buycond 和sellcond 的信息输出。
就是第一张图片上的代码。如下:
ma5:ma(close,2);
ma15:ma(close,5);
//5日均线上穿10日均线,开多
buycond:=CROSS(ma5,ma15);
if Islastbar then
begin
DEBUGFILE('D:\jzt\debug.TXT','buycond:%.0f',buycond); //输出开仓条件
end
if buycond then
begin
buy(holding=0,1,market);
if islastbar then
DEBUGFILE('D:\debug.TXT','holding:%.0f',holding);//输出HOLDING
end
//5日均线下破10日均线,平多
sellcond:=CROSS(ma15,ma5);
if islastbar then
DEBUGFILE('D:\debug.TXT',' sellcond:%.0f',sellcond);//输出平仓条件
if sellcond then
begin
sell(holding>0,1,market);
if islastbar then
DEBUGFILE('D:\debug.TXT','holding:%.0f',holding);
end