请教我想达到:赢利超过1%,回吐到70%平仓的思路,如下程序却总是第一次开仓、平仓是对的,之后每次开仓之后马上就平仓,不知问题出在什么地方。
If enterbars=0 then
begin
HigherAfterEntry:=enterprice;
LowerAfterEntry:=enterprice;
end;
else If enterbars>=1 then
begin
HigherAfterEntry:=max(HigherAfterEntry,h_1);
LowerAfterEntry:=min(LowerAfterEntry,l_1);
end;
//开多单的平仓
if holding>0 and enterbars>0 then
begin
if enterbars>=1 and HigherAfterEntry>=enterprice*(1+1/100) //成交赢利超过1%,回吐到70%出场
then
begin
price:=EnterPrice+(HigherAfterEntry-EnterPrice)*70/100;
if low<=price then
begin
sell(1,holding,limitr,min(open,price)) ;
count2:=1;
end;
end;
//开空单的平仓
if holding<0 and enterbars>0 then
begin
if enterbars>=1 and lowerAfterEntry<=enterprice*(1-1/100) //成交赢利超过1%,回吐到70%赢利出场
then
begin
price:=EnterPrice - (EnterPrice-LowerAfterEntry)*70/100;
if high>=price then
begin
sellshort(1,holding,limitr,max(open,price)) ;
count2:=1;
end;
end;