請(qǐng)教我想達(dá)到:贏利超過(guò)1%,回吐到70%平倉(cāng)的思路,如下程序卻總是第一次開(kāi)倉(cāng)、平倉(cāng)是對(duì)的,之后每次開(kāi)倉(cāng)之后馬上就平倉(cāng),不知問(wèn)題出在什么地方。
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;
//開(kāi)多單的平倉(cāng)
if holding>0 and enterbars>0 then
begin
if enterbars>=1 and HigherAfterEntry>=enterprice*(1+1/100) //成交贏利超過(guò)1%,回吐到70%出場(chǎng)
then
begin
price:=EnterPrice+(HigherAfterEntry-EnterPrice)*70/100;
if low<=price then
begin
sell(1,holding,limitr,min(open,price)) ;
count2:=1;
end;
end;
//開(kāi)空單的平倉(cāng)
if holding<0 and enterbars>0 then
begin
if enterbars>=1 and lowerAfterEntry<=enterprice*(1-1/100) //成交贏利超過(guò)1%,回吐到70%贏利出場(chǎng)
then
begin
price:=EnterPrice - (EnterPrice-LowerAfterEntry)*70/100;
if high>=price then
begin
sellshort(1,holding,limitr,max(open,price)) ;
count2:=1;
end;
end;