年假時網路上看到的,作者不可考,若有冒犯請多見諒
小弟在出場方式勉強東拼西湊加了點料 無奈還是不能用 難道區間高低點突破真的不能做5分k當沖?
請高手們有時間幫忙改一下吧 5分k當沖 手續費來回1000 小弟功力尚淺 為求突破 難道真的要自宮?
input: ORBeginTime(0845), // Opening Range Begin Time OREndTime(0930), // Opening Range End Time NoTradeTime(1300); // Don't place order after 13:00 var: mkp(0), ORHigh(0), ORLow(99999), AlreadyBuyFlag(false), AlreadySellFlag(false); SetStopContract; if date<>date[1] then begin //reset all data at begin of a new day ORHigh=0; ORLow=99999; AlreadyBuyFlag=False; AlreadySellFlag=False; end; if entrytime(0) = time and marketposition(0)=1 then AlreadyBuyFlag=true; // if entry at this bar and don't exit at this bar if entrytime(0)=time and marketposition(0)=-1 then AlreadySellFlag=true; if entrytime(1)=time and marketposition(1)=1 then AlreadyBuyFlag=true; // if entry & exit at this same bar if entrytime(1)=time and marketposition(1)=-1 then AlreadySellFlag=true; if ORBeginTime<Time and Time<=OREndTime then begin //Get Opening Range High & Low ORHigh=maxlist(ORHigh,High); ORLow=minlist(ORLow,Low); end; if Time=OREndTime then begin // Draw Opening Range Line & breakout line Value1=TL_New(Date,ORBeginTime,ORHigh,Date,OREndTime,ORHigh); Value2=TL_New(Date,ORBeginTime,ORLow,Date,OREndTime,ORLow); Value3=TL_New(Date,ORBeginTime,ORHigh+2*(MinMove/PriceScale),Date, OREndTime,ORHigh+2*(MinMove/PriceScale)); Value4=TL_New(Date,ORBeginTime,ORLow-2*(MinMove/PriceScale),Date, OREndTime,ORLow-2*(MinMove/PriceScale)); end; if OREndTime < Time and Time<NoTradeTime then begin // Place order for entry if AlreadyBuyFlag=false and highd(0)-lowd(0)<70 and close<closed(1)*1.06 then buy next bar at ORHigh+2*(MinMove/PriceScale) stop; if AlreadySellFlag=false and highd(0)-lowd(0)<70 and close>closed(1)*0.94 then sellshort next bar at ORLow-2*(MinMove/PriceScale) stop; end; mkp=marketposition; if marketposition=1 then begin sell next bar at entryprice-40 stop; if highest(high,barssinceentry)-entryprice<50 then sell next bar at highest(high,barssinceentry)-average(high-low,5)*4 stop; if time>1325 then sell next bar at lowest(low,3)-1 stop; if time>1335 then sell this bar on close; SetPercentTrailing(40*50,80); end; if marketposition=-1 then begin buytocover next bar at entryprice+40 stop; if entryprice-lowest(low,barssinceentry)<50 then buytocover next bar at lowest(low,barssinceentry)+average(high-low,5)*4 stop; if time>1325 then buytocover next bar at highest(high,3)+1 stop; if time>1335 then buytocover this bar on close; SetPercentTrailing(80*50,10); end; setexitonclose;