{策略說明:每分鐘加碼一口買單,加到第五口之後全部平倉,不斷循環} input:maxPosition(5); Vars:nowPosition(0); Vars:signDTStr(""); {宣告放在變數區} DefineDLLFunc: "C:\Program Files\OrderMaster\OMSignAPI.dll",bool,"IniDllAndPosition",LPSTR,int; DefineDLLFunc: "C:\Program Files\OrderMaster\OMSignAPI.dll",bool,"GoOrder",LPSTR,LPSTR,LPSTR,int,double; {取得倉位:若沒有初始化倉位,會回傳 99999} DefineDLLFunc: "C:\Program Files\OrderMaster\OMSignAPI.dll",int,"GetNowPosition",LPSTR; if date<>date[1] then begin {留倉用 If currentbar=1 then begin} exitlong at close; exitshort at close; {初始化} IniDllAndPosition("TW_001", 0); {當沖 =0} nowPosition = 0; end; if nowPosition < maxPosition then begin buy("B") next bar at market; signDTStr = numtostr(year(date)+1900,0) +"/" + numtostr(month(date),0) + "/" + numtostr(dayofmonth(date),0) + " " + numtostr(time,0) + "00"; {下單:因為用 next bar 所以是下上一支的,倉位要加 1,才會和 TS 同步} GoOrder("TW_001", "", signDTStr , nowPosition+1, Close); nowPosition = nowPosition + 1; end else begin exitlong next bar at market; signDTStr = numtostr(year(date)+1900,0) +"/" + numtostr(month(date),0) + "/" + numtostr(dayofmonth(date),0) + " " + numtostr(time,0) + "00"; {平倉} GoOrder("TW_001", "", signDTStr , 0, Close); nowPosition = 0; end;