停利停損的計算

  •   267 
  • 最後發表   大A  2025 三月 31
大A 發文於   2025/03/31

趴文找到

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;

但回測時還是不會觸發停利停損,請問這要怎麼修改?

排序方式: 標準 | 最新
虎科大許教授 發文於   2025/03/31

if close>filledAvgPrice+(_high-_low) or close<filledAvgPrice-(_high-_low) then setposition(0,market);

大A 發文於   2025/03/31

丫,手誤了  感謝教授提醒

發表回覆
Close