趴文找到
1.您可以在進場條件成立時用變數紀錄高低點
舉例來說:
var: intrabarpersist _high(0), intrabarpersist _low(0);
condition1 = 進場條件;
if condition1 and position = 0 and filled = 0 then begin
setposition(1, market);
_high = high;
_low = low;
end;
_high 和 _low 就會記錄進場當下的該根Bar高低點。
改成自已測試的條件
if barfreq<>"Min"or barinterval<>30 then return;
var:intrabarpersist _high(0),intrabarpersist _low(0);
condition1=Close>high[1] and close>open;
if position=0 and filled=0 and condition1 then begin
setposition(1,market);
_high=high;
_low = low;
end;
if position=1 and filled=1 then begin
if close>filledAvgPrice+(_high-_low) or close<filledAvgPrice-(_high-_low) then setposition(1,market);
end;
但回測時還是不會觸發停利停損,請問這要怎麼修改?
2 評論