variable:lossnum=0;// 全局变量,平仓时判断一下是盈利/亏损,
if 平仓条件 and holding>0 then
begin
sell(1,HOLDING,MARKET);
if c<enterprice then lossnum:=lossnum+1;
if c>enterprice then lossnum:=0;//盈利置0
end
if 开仓条件 and holding=0 and lossnum<cs then buy(1,1+lossnum,MARKET);//亏损次数+1为当前开仓手数
没有cs这个条件,直接去掉就行了。这是伪代码,条件是需要你自己的填充的。
variable:lossnum=0;// 全局变量,平仓时判断一下是盈利/亏损,
if 平仓条件 and holding>0 then
begin
sell(1,HOLDING,MARKET);
if c<enterprice then lossnum:=lossnum+1;
if c>enterprice then lossnum:=0;//盈利置0
end
if 开仓条件 and holding=0 then buy(1,1+lossnum,MARKET);//亏损次数+1为当前开仓手数
[此贴子已经被作者于2018/9/28 22:10:48编辑过]