新交易系统下,平仓前出现多个买入信号,怎样才能只确认第一个,忽略其他信号直到平仓再开。
开仓条件中加入HOLDING=0,限制只有在没有仓位时才开仓
以下为简单示例,供参考.
如果您刚接触金字塔,推荐您多看看"帮助"菜单下的内容,如:视频教程和文档教程
ma5:ma(close,5);
ma15:ma(close,15);
if CROSS(ma5,ma15) and time>093000 and time<151000 then
begin
sellshort(holding<0,1,market);
buy(holding=0,1,limit,c+2*mindiff);
end
if CROSS(ma15,ma5) and time>093000 and time<151000 then
begin
sell(holding>0,0,market);
buyshort(holding=0,1,limit,c-2*mindiff);
end
//收盘前5分钟平仓
if time > 151000 then
begin
sell(holding > 0, 0, thisclose);
sellshort(holding < 0, 0, thisclose);
end