這是我之前玩HTS時
程式交易中有一個Alert的指令
可以在達到條件時發出聲音
可是因為會連續不斷的叫
所有點煩人
我自己想了一個方法來解決
之前有發表在聚財網
現在在這裡重貼一下
也算是留個記錄
程式碼如下:
if 買進條件 then
if currentcontracts = 0 then
Alert("多單買")
end if
Buy this bar at open or lower
Buy this bar at open or higher
end if
if 平倉條件 then
if currentcontracts <> 0 then
Alert("多單平")
end if
exitlong this bar at open or higher
exitlong this bar at open or lower
end if
基本原理是以currentcontracts來判斷手上有沒有單
(因為在第一次叫完,理論上程式交易應該已經進單)
所以就可以只叫一次
(依設定的秒數及音樂長度而有不同)
但缺點是沒辦法在加碼的時後使用
程式交易中有一個Alert的指令
可以在達到條件時發出聲音
可是因為會連續不斷的叫
所有點煩人
我自己想了一個方法來解決
之前有發表在聚財網
現在在這裡重貼一下
也算是留個記錄
程式碼如下:
if 買進條件 then
if currentcontracts = 0 then
Alert("多單買")
end if
Buy this bar at open or lower
Buy this bar at open or higher
end if
if 平倉條件 then
if currentcontracts <> 0 then
Alert("多單平")
end if
exitlong this bar at open or higher
exitlong this bar at open or lower
end if
基本原理是以currentcontracts來判斷手上有沒有單
(因為在第一次叫完,理論上程式交易應該已經進單)
所以就可以只叫一次
(依設定的秒數及音樂長度而有不同)
但缺點是沒辦法在加碼的時後使用
全站熱搜