variable:n=0,m=0;
if 平仓条件 and holding判断 then begin
平仓语句;
if 大盈利 then begin
n:=1;
m:=0;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end
开仓条件加入:barslast(n=1 and ref(n=0,1))>一段时间 or barslast(m=2 and ref(m=1,1))>一段时间
我自己 顶一个 ,
//交易控制变量
variable:DYL=0;
variable:大盈利=0;
if 大盈利:=abs(enterprice-EXITPRICE)>=40 and DYL=0 THEN BEGIN
DYL:=1;
盈利休止:=DYL=1 AND EXITBARS<=40;
end
if 大盈利:=abs(enterprice-EXITPRICE)<40 and DYL=1 THEN BEGIN
DYL:=0;
end
另外 这是我自己按照对函数的理解 写出的一个盈利停盘 条件
在开仓条件 and not(盈利休止)//在大盈利后 平仓历时40个周期内不交易
但是 这个代码 有问题
已经根据版主的意思修改了代码 但是 不管n=1还是n=0 我都试过了
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
这段一加进来 代码就不管用,连 连续亏损停盘也不起作用了;
if a4 and tpcc=1 then BEGIN
平多4:SELL(1,lots,MARKETR),orderqueue;
tpcc:=0;
debugfile('D:\590191352.txt', '平多4 %.0f',holding );
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end
if a5 and tpcc=1 then BEGIN
平多5:SELL(1,lots,MARKETR),orderqueue;
tpcc:=0;
debugfile('D:\590191352.txt', '平多5 %.0f',holding );
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end
if a6 and tpcc=1 then BEGIN
平多6:SELL(1,lots,MARKETR),orderqueue;
tpcc:=0;
debugfile('D:\590191352.txt', '平多6 %.0f',holding );
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end
if a3 and tpcc=1 then BEGIN
止损平多3:SELL(1,lots,MARKETR),orderqueue;
tpcc:=0;
debugfile('D:\590191352.txt', '止损平多3 %.0f',holding );
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end
if b4 and tpcc=2 then BEGIN
平空4:SELLSHORT(1,lots,MARKETR),orderqueue;
tpcc:=0;
debugfile('D:\590191352.txt', '平空4 %.0f',holding );
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end
if b5 and tpcc=2 then BEGIN
平空5:SELLSHORT(1,lots,MARKETR),orderqueue;
tpcc:=0;
debugfile('D:\590191352.txt', '平空5 %.0f',holding );
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end
if b6 and tpcc=2 then BEGIN
平空6:SELLSHORT(1,lots,MARKETR),orderqueue;
tpcc:=0;
debugfile('D:\590191352.txt', '平空6 %.0f',holding );
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end
if b3 and tpcc=2 then BEGIN
止损平空3:SELLSHORT(1,lots,MARKETR),orderqueue;
tpcc:=0;
debugfile('D:\590191352.txt', '平空3 %.0f',holding );
if numprofit(1)>12000 then begin
m:=0;
n:=1;
end
if numprofit(1)>0 then m:=0;
if numprofit(1)<0 then m:=m+1;
end