Hello jack121974,
小幫手會建議您使用自動交易腳本,有position和filled會比較好控制變數取得所需數值。
如果要在警示腳本中達到相同的要求,那麼就需要另外用個變數來標記進場。
舉例來說:
input: _barNum(50, "設定資料讀取筆數(要和進場腳本相同)");
var: _pos(0);
settotalbar(_barNum);
condition1 = volume>volume[1]* 1.3 and close>simplehighest(getfield("High", "D")[1],20);
if condition1 and currentbar > _barNum and _pos = 0 then begin
value1 = low;
_pos = 1;
end;
if close cross under value1 and _pos = 1 then begin
_pos = 0;
ret = 1;
end;
這邊設了一個 _pos 來標記進場,當進場條件符合後 _pos 就會變成1,避免尚未出場時條件再度符合時最低價的值又被更新。
currentbar > _barNum 是避免在資料讀取筆數運算時 _pos 就被改變。
2 評論