
runmode:0;
input:waitperiodmins(30);
input:inittradesendtime(143000);
input:liqrevendtime(110000);
input:thrustprcnt1(0.3);
input:thrustprcnt2(0.6);
input:breakoutprcnt(0.25);
input:failedbreakoutprcnt(0.25);
input:protstopprcnt1(0.25);
input:protstopprcnt2(0.15);
input:protstopamt(3);
input:breakevenprcnt(0.5);
input:avgrnglength(10);
input:avgoclength(10);
variable:averagerange=0;
variable:averageocrange=0;
variable:cantrade=0;
variable:buyeasierday=false;
variable:selleasierday=false;
variable:buybopoint=0;
variable:sellbopoint=0;
variable:longbreakpt=0;
variable:shortbreakpt=0;
variable:longfbopoint=0;
variable:shortfbopoint=0;
variable:barcount=0;
variable:intrahigh=0;
variable:intralow=999999;
variable:buystoday=0;
variable:sellstoday=0;
variable:currtrdtype=0;
variable:longliqpoint=0;
variable:shortliqpoint=0;
variable:yesterdayocrrange=0;
variable:intratradehigh=0;
variable:intratradelow=999999;
m1:=ref(ma(callstock(stklabel,vthigh,6,0)-callstock(stklabel,vtlow,6,0),10),1);
m2:=ref(ma(abs(callstock(stklabel,vtopen,6,0)-callstock(stklabel,vtclose,6,0)),10),1);
m3:=ref(llv(low,3),1);
m4:=ref(hhv(high,3),1);
if date>ref(date,1) then begin
averagerange:=m1;
yesterdayocrrange:=abs(open-close);
averageocrange:=m2;
cantrade:=0;
if yesterdayocrrange<0.85*averageocrange then cantrade:=1;
buyeasierday:=false;
selleasierday:=false;
if callstock(stklabel,vtclose,6,-1)<=callstock(stklabel,vtclose,6,-2) then buyeasierday:=true;
if callstock(stklabel,vtclose,6,-1)>callstock(stklabel,vtclose,6,-2) then selleasierday:=true;
if buyeasierday then begin
buybopoint:=callstock(stklabel,vtopen,6,0)+thrustprcnt1*averagerange;
sellbopoint:=callstock(stklabel,vtopen,6,0)-thrustprcnt2*averagerange;
end
if selleasierday then begin
sellbopoint:=callstock(stklabel,vtopen,6,0)-thrustprcnt1*averagerange;
buybopoint:=callstock(stklabel,vtopen,6,0)+thrustprcnt2*averagerange;
end
longbreakpt:=callstock(stklabel,vthigh,6,-1)+breakoutprcnt*averagerange;
shortbreakpt:=callstock(stklabel,vtlow,6,-1)-breakoutprcnt*averagerange;
shortfbopoint:=callstock(stklabel,vthigh,6,-1)-failedbreakoutprcnt*averagerange;
longfbopoint:=callstock(stklabel,vtlow,6,-1)+failedbreakoutprcnt*averagerange;
barcount:=0;
intrahigh:=0;
intralow:=999999;
buystoday:=0;
sellstoday:=0;
currtrdtype:=0;
end
if high>intrahigh then intrahigh:=high;
if low<intralow then intralow:=low;
barcount:=barcount+1;
if barcount>waitperiodmins/datatype and cantrade=1 then begin
if holding=0 then begin
intratradehigh:=0;
intratradelow:=999999;
end
if holding>0 then begin
intratradehigh:=max(intratradehigh,high);
buystoday:=1;
end
if holding<0 then begin
intratradelow:=min(intratradelow,low);
sellstoday:=1;
end
if buystoday=0 and time<inittradesendtime then
LBreakOut:buy(1,1,stop,buybopoint);
if sellstoday=0 and time<inittradesendtime then
SBreakout:sellshort(1,1,stop,sellbopoint);
if intrahigh>longbreakpt and sellstoday=0 and time<inittradesendtime then
SfailedBO:sellshort(1,1,stop,shortfbopoint);
if intralow<shortbreakpt and buystoday=0 and time<inittradesendtime then
BfeiledBO:buy(1,1,stop,longfbopoint);
if holding>0 then begin
longliqpoint:=enterprice-protstopprcnt1*averagerange;
longliqpoint:=min(longliqpoint,enterprice-protstopamt);
if ref(holding,1)<0 and enterbars>=1 and ref(high,1)>=shortliqpoint and shortliqpoint<shortfbopoint then
currtrdtype:=-2;
if currtrdtype=-2 then begin
longliqpoint:=enterprice-protstopprcnt2*averagerange;
longliqpoint:=min(longliqpoint,enterprice-protstopamt);
end
if intratradehigh>=enterprice+breakevenprcnt*averagerange then
longliqpoint:=enterprice;
if time>=inittradesendtime then
longliqpoint:=max(longliqpoint,m3);
if time<liqrevendtime and sellstoday=0 and longliqpoint<>enterprice and enterbars>=4 then begin
LongLiqRev:sellshort(1,1,stop,longliqpoint);
end else begin
LongLiq:sell(1,1,stop,longliqpoint);
end
end
if holding<0 then begin
shortliqpoint:=enterprice+protstopprcnt1*averagerange;
shortliqpoint:=max(shortliqpoint,enterprice+protstopamt);
if ref(holding,1)<0 and enterbars>=1 and ref(low,1)<longliqpoint and longliqpoint>longfbopoint then
currtrdtype:=2;
if currtrdtype=2 then begin
shortliqpoint:=enterprice+protstopprcnt2*averagerange;
shortliqpoint:=max(shortliqpoint,enterprice+protstopamt);
end
if intratradelow<=enterprice-breakevenprcnt*averagerange then
shortliqpoint:=enterprice;
if time>=inittradesendtime then
shortliqpoint:=min(shortliqpoint,m4);
if time<liqrevendtime and buystoday=0 and shortliqpoint<>enterprice and enterbars>=4 then begin
ShortLiqRev:buy(1,1,stop,shortliqpoint);
end else begin
ShortLiq:sellshort(1,1,stop,shortliqpoint);
end
end
end
if time>=closetime(0) then begin
sell(1,holding,limitr,close);
sellshort(1,holding,limitr,close);
end
盈亏:asset-500000,noaxis,coloryellow,linethick2;
[此贴子已经被作者于2011-11-18 22:33:16编辑过]