想寫一個用在台指期的停損警示,但filledavgprice沒辦法用

  •   314 
  • 最後發表   Ku0jinx  2025 四月 14
Ku0jinx 發文於   2025/04/11

如題,想寫一個在台指期進場後跌50點就發出提醒的警示,但是在警示裡沒辦法用filledavgprice來取得目前的未平倉成本,想請教該怎麼修正,語法如下

// === 宣告變數 ===

Vars: isLong(false), isShort(false), myEntryPrice(0), stopPrice(0), stopLossAlert(false);

 

 

// === 多單停損檢查 ===

If isLong Then

Begin

    stopPrice = myEntryPrice - 10;

    If Low <= stopPrice Then

        stopLossAlert = true;

End;

 

// === 空單停損檢查 ===

If isShort Then

Begin

    stopPrice = myEntryPrice + 10;

    If High >= stopPrice Then

        stopLossAlert = true;

End;

 

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

If Position>0 and Filled>0 Then

Begin

    stopPrice = FilledAvgPrice - 10;

    If Low <= stopPrice Then

        stopLossAlert = true;

End;

Ku0jinx 發文於   2025/04/12

謝謝教授的解答,但警示腳本跟指標腳本好像都不能用Potition Filled跟FilledAvgPrice,因為自動交易中心如果手動去進出場都會有問題,所以我想做的是做一個根據進場的點位做一個固定點數的停損的警示提醒,但警示跟指標腳本好像都不能用FilledAvgPrice去抓取進場的部位

附加文件

Ku0jinx 發文於   2025/04/12

沒事了謝謝教授,我試試看用交易腳本用Alert不用setposition做買賣的動作只出現警示,再用警示提示視窗再加上手機推播看看能不能一樣達到停損提醒的效果

XS小編 發文於   2025/04/14

Hello Ku0jinx,

 

小編補充,Potition、Filled跟FilledAvgPrice 是交易函數,只能夠使用在交易腳本中。

不過您在交易腳本中若沒有交易的動作話,Potition、Filled跟FilledAvgPrice都會維持在0。

建議可以用變數來模擬記錄進出場的庫存和價格。

發表回覆
Close