//买开执行
if cond1 and time <151200 then
begin
if holding<0 then bp0:SELLSHORT(1,0,THISCLOSE);//平空
if holding=0 then bk1:buy(1,1,THISCLOSE);//开多
exit;
end
//平多:
if (cond3 or cond31) and holding>0 then
begin
sp1:SELL(1,0,THISCLOSE);//平多
end
//卖开执行
if cond2 and time <151200 then
begin
if holding>0 then sp0:SELL(1,0,THISCLOSE);//平多
if holding=0 then sk1:buySHORT(1,1,THISCLOSE);//开空
exit;
end
//多单止损
cond32:=close<Ma(close,5);
if holding>0 then
begin
bkpp:=AVGENTERPRICE;
if close<bkpp-losspoint and cond32 then 多单止损:SELL(1,0,THISCLOSE);//平多
exit;
end
//空单止损
cond41:=close>MA(close,5);
if holding<0 then
begin
skpp:=AVGENTERPRICE;
if close>skpp+losspoint and cond41 then 空单止损:SELLSHORT(1,0,THISCLOSE);//平空
exit;
end
//收盘平仓
if time >151200 and holding<>0 then
begin
if holding<0 then 收盘平空:SELLSHORT(1,0,THISCLOSE);//平空
if holding>0 then 收盘平多:SELL(1,0,THISCLOSE);//平多
end
不明白你exit的意思 同一根开平用enterbar去控制就行了。
没有完整的代码,不清楚你这个为什么没有在收盘前平仓。
你试着自己用金字塔的调试功能 单步跟踪下看看。若不会用的话,参考金字塔高级教程。