您好,论坛里有关限制每天开仓手数问题一大堆,希望用户能够自行搜索。
以下为实例
variable:num=0;// 全局变量,来控制当天交易次数
cs:=5;//限定一天最多交易5次
ma5:=ma(5,close);//5日均线
ma20:=ma(20,close);
con1:=cross(ma5,ma20);//5日均线金叉20日均线
con2:=cross(ma20,ma5);//死叉
sell(con2 and holding>0,1,market);//死叉平多
//金叉,且交易次数小于5,开多
if cond1 and holding=0 and lossnum<5 then
begin
buy(1,1,market);
num:=num+1;
end
if time=closetime(0) then num:=0;// 收盘的同时,num赋值为0
//收盘num不赋值为0,第二天就不再开仓了