input : r(4),BeginTime(0900),EndTime(1245); var :TH(0),TL(0),mkp(0),ax(0),ay(0),aa(0),bb(0); if date <> date[1] then begin mkp=0; ax=0; ay=0; aa=0; bb=0; TH=high; TL=low; end; if high > TH then begin TH=high; aa=aa+1; end; if low < TL then begin TL=low; bb=bb+1; end; if BeginTime < Time and Time < EndTime then begin if MarketPosition = 0 and ax < 1 and aa > r and aa > bb then buy at highd(0)+1 stop; if MarketPosition = 0 and ay < 1 and bb > r and bb > aa then sell at lowd(0)-1 stop; end; mkp=marketposition; if mkp[1] <> 1 and mkp=1 then ax=ax+1; if mkp[1] <> -1 and mkp=-1 then ay=ay+1; if marketposition =1 then begin exitlong at entryprice-50 stop ; if highest(h,barssinceentry)-entryprice < 50 then exitlong at lowest(low,24)-1 stop; exitlong at highd(0)*0.985 stop; if time>1339 then exitlong this bar on close; end; if marketposition =-1 then begin exitshort at entryprice+50 stop ; if entryprice-lowest(h,barssinceentry) < 50 then exitshort at highest(high,24)+1 stop; exitshort at lowd(0)*1.015 stop; if time>1339 then exitshort this bar on close; end; setexitonclose;
這是 TS 2000i 的程式碼,交易指令要改變,且要加 next bar 指令
現在的 TS 8 系列已不支援這重舊語法,需要自已修改差異處
input : r(4),BeginTime(0900),EndTime(1245); var :TH(0),TL(0),mkp(0),ax(0),ay(0),aa(0),bb(0); if date <> date[1] then begin mkp=0; ax=0; ay=0; aa=0; bb=0; TH=high; TL=low; end; if high > TH then begin TH=high; aa=aa+1; end; if low < TL then begin TL=low; bb=bb+1; end; if BeginTime < Time and Time < EndTime then begin if MarketPosition = 0 and ax < 1 and aa > r and aa > bb then buy next bar at highd(0)+1 stop; if MarketPosition = 0 and ay < 1 and bb > r and bb > aa then sellshort next bar at lowd(0)-1 stop; end; mkp=marketposition; if mkp[1] <> 1 and mkp=1 then ax=ax+1; if mkp[1] <> -1 and mkp=-1 then ay=ay+1; if marketposition =1 then begin sell next bar at entryprice-50 stop ; if highest(h,barssinceentry)-entryprice < 50 then sell next bar at lowest(low,24)-1 stop; sell next bar at highd(0)*0.985 stop; if time>1339 then sell this bar on close; end; if marketposition =-1 then begin buytocover next bar at entryprice+50 stop ; if entryprice-lowest(h,barssinceentry) < 50 then buytocover next bar at highest(high,24)+1 stop; buytocover next bar at lowd(0)*1.015 stop; if time>1339 then buytocover this bar on close; end; setexitonclose;