程式交易大方向分成當沖與波段,但是在設計當沖程式的時候有些
觀念看似簡單,但是卻是很多人容易忽略的地方。
在這裡歸納幾個要點:
了;假定訊號出現的時間為 8:45 ~ 13:30這段期間,然後 13:35 平
倉。
TS程式碼:
HTS程式碼:
觀念看似簡單,但是卻是很多人容易忽略的地方。
在這裡歸納幾個要點:
- 不留倉:當沖程式不能留倉,所以一定要在收盤前平倉,而
且要避免在最後結束才平倉,因為當 13:45 才出現訊號,這
筆交易應該是不會成功的。 - 變數重設:當沖程式每天的變數都必須重新初始化,這樣才
確保資料的正確性。 - 訊號的時間範圍:當沖程式出現的訊號最主要要避免平倉後
又出現新的訊號,這樣子會出現訊號錯誤的問題。
了;假定訊號出現的時間為 8:45 ~ 13:30這段期間,然後 13:35 平
倉。
TS程式碼:
if date[1] <> date[0] then begin
{ initial variables }
end;
If time >= 0845 and time < 1330 then begin
{ signal code }
end;
If time = 1335 and CurrentContracts <> 0 then begin
exitlong("XL") this bar on close;
exitshort("XS") this bar on close;
end;
HTS程式碼:
if date[1] <> date[0] then
/* initial variables */
end if
If time >= 084500 and time < 133000 then
/* signal code */
end if
If time = 133500 and CurrentContracts <> 0 then
exitlong("XL") this bar on close
exitshort("XS") this bar on close
end if
全站熱搜