請問小編和教授,對於連續外盤成 交的寫法,在參考眾多的說明後,這樣的寫法是否可行?
麻煩請解惑!!!感恩感恩
// 確保為 1 分鐘線頻率
if barFreq <> "min" or barInterval <> 1 then
raiseRunTimeError("請設定 1 分鐘頻率");
input: TickCountThreshold(5, "連續外盤成交次數"), VolumeThreshold(100, "成交量閾值");
var: _outTickCount(0), _outVolume(0), _lastClose(0);
// 初始化變數
_outTickCount = 0;
_outVolume = 0;
_lastClose = Close;
// 判定是否為外盤成交
if Close > _lastClose then begin
_outTickCount = _outTickCount + 1;
_outVolume = _outVolume + Volume;
end else begin
// 重置計數,因為沒有連續外盤成交
_outTickCount = 0;
_outVolume = 0;
end;
// 判斷條件是否滿足
if _outTickCount >= TickCountThreshold and _outVolume >= VolumeThreshold then begin
Plot(1, Close, "轉折信號", checkbox:=1);
end;
// 更新上一筆的收盤價
_lastClose = Close;
2 評論