在盤中常常發現某些整點時間或特定時間週期會突然有許多系統單同時出來 特別是長週期的突破系統,通常會在突破後的下一個整點時間全數出籠, 因此出現滑價或買不到好價位 針對這個問題,可以用語法來解決,讓你比別人快幾秒進場,甚至可以吃點別人的豆腐 一般程序化交易系統都往往會在這根bar結束(buy this bar at close)或是下根bar開始(buy next bar at open)時送出委託單,如果你可以在這根bar結束前就進場,自然比別人更佔便宜! 這裡把送出委託單的時間在往前移10秒,必須啟動IntrabarOrderGeneration才能正常運作。 在Multicharts裡設置 Format(格式)->Signal(信號)->Fomat(設置)->IntrabarOrderGeneration(Bar內產生委託) 01.vars: 02. intrabarpersist waitingForBuy(false), 03. intrabarpersist mySec(0), 04. intrabarpersist myEntrySec(0); 05. 06.if barstatus=0 then begin 07. mySec = currenttime_s; 08. myEntrySec = currenttime_s+barinterval*60-10; 09.end else begin 10. mySec = mySec[1]; 11. myEntrySec = myEntrySec[1]; 12.end; 13. 14.if {your entry condition} then begin 15. waitingForBuy = true; 16.end; 17. 18.if waitingForBuy and currenttime_s>=myEntrySec then begin 19. buy next bar at open; 20. waitingForBuy =false; 21.end; 本文转自http://www.aboutels.com/thread-146-1-1.html