用variable定义全局变量N=0,在每次平仓的时候就加1
同时在开仓条件里加上N<3
以下为全局变量部分示例,供您参考:
目标:当日亏损交易次数超过3次,则不再开仓如何写?----图表交易 新交易函数
variable:lossnum=0;// 全局变量,平仓时判断一下是盈利/亏损,若亏损lossnum就加1
if cond1 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then lossnum:=lossnum+1;
end
if cond2 and holding=0 and lossnum<3 then buy(1,1,thisclose);
if time=150000 then lossnum:=0;// 商品期货,收盘的同时,lossnum赋值为0
//收盘lossnum不赋值为0,后面就不再开仓了