{範例一:感謝熱心用戶提供} {目前僅能使用於MC x86 , 暫不支援MC 64} {宣告} variables:nowposition(0),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 IniDllAndPosition("TXF", 0); end; buy{買策略} buy..... nowposition = 1; sellshort{賣策略} sellshort ...... nowposition = -1; exit{出場策略} sell...... or buytocover .... nowposition = 0; {call api} if nowPosition = 1 then begin signDTStr = numtostr(year(date)+1900,0) +"/" + numtostr(month(date),0) + "/" + numtostr(dayofmonth(date),0) + " " + numtostr(time,0) + "00"; GoOrder("TXF", "", signDTStr , nowPosition, Close); end; if nowPosition = 0 then begin signDTStr = numtostr(year(date)+1900,0) +"/" + numtostr(month(date),0) + "/" + numtostr(dayofmonth(date),0) + " " + numtostr(time,0) + "00"; GoOrder("TXF", "", signDTStr , nowPosition, Close); end; if nowPosition = -1 then begin signDTStr = numtostr(year(date)+1900,0) +"/" + numtostr(month(date),0) + "/" + numtostr(dayofmonth(date),0) + " " + numtostr(time,0) + "00"; GoOrder("TXF", "", signDTStr , nowPosition, Close); end; {----------------------------------------------------------------------------------} {範例二:感謝熱心用戶提供} Inputs: Auto(0); Vars:nowposition(0) if Auto=1 then begin 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; DefineDLLFunc: "C:\Program Files\OrderMaster\OMSignAPI.dll",int,"GetNowPosition",LPSTR; nowposition=marketposition*currentcontracts; if date<>date[1] then IniDllAndPosition("MXF", nowposition); end; nowposition=marketposition*currentcontracts; if Auto=1 then begin if nowposition = 0 then begin signDTStr = numtostr(year(date)+1900,0) +"/" + numtostr(month(date),0) + "/" + numtostr(dayofmonth(date),0) + " " + numtostr(time_s,0); GoOrder("MXF", "", signDTStr , nowposition, ExitPrice(0)); end else begin signDTStr = numtostr(year(date)+1900,0) +"/" + numtostr(month(date),0) + "/" + numtostr(dayofmonth(date),0) + " " + numtostr(time_s,0); GoOrder("MXF", "", signDTStr , nowposition, EntryPrice(0)); end; end;