當沖,就是讓系統判斷若您在快收盤時還有倉位,就即時平倉掉,其程式碼說明如下

 

 

if time>=134000 and marketposition<>0 then

        exitlong("收平A") next bar at market

        exitshort("收平B") next bar at market

end if

 

 

 

以上的語法翻譯如下:

if      time      >=      134000  and    marketposition<>0          then

如果   時間    大於等於  13:40    而且   目前庫存有一口多單或空單     

    

      exitlong("收平A")  next  bar   at   market

      多單平倉              下一根 k       市價

      exitshort("收平B") next bar at market

      空單平倉              下一根 k        市價

 

end if

以上條件結束

 

在此要特別注意,由於結算日的期貨的收盤時間為13:30 ,因此在設定時間要特別注意,以免回測時產生誤差

arrow
arrow
    全站熱搜

    阿豪 發表在 痞客邦 留言(0) 人氣()