程式交易走過的雷

1.setexitonclose 當沖平倉出場

問題點:只適用於回測,實際交易會有不成交而留倉的風險。

解決(參考張林忠老師-關鍵報告):

if marketposition >0 and time >1339 then sell next bar at market;

if marketposition <0 and time >1339 then buytocover next bar at market;

2.波段留倉但結算日不在第三個週三,特別將那幾天列出來

3.結算平倉(張林忠老師-關鍵報告)

condition1 = (dayofweek(date) =3 and dayofmonth(date)>14 and dayofmonth(date)<22) or date = 1040127 or date = 10702226 or date =1100222 or date = 1100617;

if condition1 = true then begin if time >1314 then begin sell this bar on close;buytocover this bar on close; end ;end ;

回到頂端