PHP 代码:
Input:nmin(30,10,60,10); //设置参数
input:noffset(3,1,20,1); //设置参数
input:lots(1,1,1000,1); //设置参数
cyc:=barslast(date>ref(date,1))+1; //统计日内k线数
highestof30min:=valuewhen(time<=90000+nmin*100,hhv(h,cyc)); {在从开盘到设定时间(默认参数开盘30分)内保存当天最高价}
lowestof30min:=valuewhen(time<=90000+nmin*100,llv(l,cyc)); {在从开盘到设定时间(默认参数开盘30分)内保存当天最低价}
if high >= highestof30min + noffset*mindiff and holding<=0 then {如果最高价突破设定时间内的前高加设定偏移并且目前没有多单,那么}
begin
myprice: = highestof30min + noffset*mindiff; {预设进场价.既等于设定时间内的前高加设定偏移}
if open > myprice then {如果开盘价大于预设进场价,那么奋不顾身闯进去,(注:这是移植的,原设计并不一定完美,这时可能不是那么好成交的,我也不必多费唇舌了).}
begin
myprice: = open;
sellshort(holding<0,0,limitr,myprice); {如果有空单先平}
buy(holding=0,lots,limitr,myprice); {如果没有多单则以开盘价开多lots手}
end
end
if low <= lowestof30min - noffset*mindiff and holding>=0 then {以下开空部分同上,只不过方向相反}
begin
myprice: = lowestof30min - noffset*mindiff;
if open < myprice then begin
myprice: = open;
sell(holding>0,0,limitr,myprice);
buyshort(holding=0,lots,limitr,myprice);
end
end
if time >= 145900 then {收盘平仓}
begin
sell(holding>0,0,limitr,open);
sellshort(holding<0,0,limitr,open);
end