IF 條件A then begin
buy();
if 條件B then sell();
END
IF 條件C then buy();
以上代碼,條件B成立后的平倉(cāng),是否只針對(duì)條件A的開(kāi)倉(cāng)?
還是說(shuō)條件C開(kāi)倉(cāng)后,只要條件B成立,仍然會(huì)平倉(cāng)?
有什么辦法 讓條件B的平倉(cāng) 在任何時(shí)候只針對(duì)條件A的開(kāi)倉(cāng)呢
variable:n=0;
IF 條件A and n=0 and holding=0 then begin
buy();
n:=1;
end
if 條件B and n=1 and holding>0 then begin
sell();
n:=0;
END
IF 條件C and holding=0 and n=0 then begin
buy();
n:=2;
end
用全局變量來(lái)記錄下單狀態(tài),要平掉條件c的倉(cāng), 用n=2來(lái)判斷