一持倉多天策略執行後,我設定加碼1次後,到達停損點後停損.
但這樣寫發現有2個問題:
1.回測時或模擬實單雖有執行加碼動作,但自交易不只會幫我加碼1次(可能多次)
2.無法加碼後達到停損點幫我出場.
想問如何修改成,只能加碼1次,並且到達停損點後停損.感謝~~
部分程式碼如下:
input: loss(20,"停損");
if filled > 0 and add = 0 and close <= filledAvgPrice * (1 - 0.01 * loss) then begin
setposition(position , market,label:="加碼");
add = 1;
end;
//加碼後停損
if filled > 0 and add = 1 and close <= filledAvgPrice * (1 - 0.01 * loss) then begin
setposition(0, market,label:="加碼後停損");
add = 0;
end;
1 評論