能把這個模型改成股指一分鐘用的嗎?
variable:zs=c,maxhl=c;
//把以上顧比線的代碼復制一下
DISTL:=NEWLBARS(L,1);
DISTH:=NEWHBARS(H,1);
HI20:=REF(HHV(H,20),1);
LO20:=REF(LLV(L,20),1);
GBD1:=REF(L,DISTL);
GBD2:=REF(GBD1,DISTL);
GBD:=IF(GBD2>0,MAX(LLV(L,20),GBD2),LLV(L,20));
GBG1:=REF(H,DISTH);
GBG2:=REF(GBG1,DISTH);
GBG:=IF(GBG2>0,MIN(HHV(H,20),GBG2),HHV(H,20));
nn:=barslast(date<>ref(date,1))+1;
entertime:=nn>=m and time<=144500;
exittime:=time>=150900;
if holding>0 then 止損1:zs;
if holding<0 then 止損2:zs;
ma5:=ma(c,5);
ma30:=ma(c,30);
long:=cross(ma5,ma30);//多單進場條件
short:=cross(ma30,ma5);//空單進場條件
//下破移動止損線后離場
if holding>0 and (c<zs or exittime) then sell(1,1,limitr,c);
if holding<0 and (c>zs or exittime) then sellshort(1,1,limitr,c);
//開倉語句
if holding=0 and entertime and long then begin
buy(1,1,limitr,c);
zs:=gbd;//調用顧比倒數線做為止損
maxhl:=h;//記錄當時的高點
end
if holding=0 and entertime and short then begin
buyshort(1,1,limitr,c);
zs:=gbg;//調用顧比倒數線做為止損
maxhl:=L;
end
if holding<0 and l<maxhl then begin //創新低后,重新定位離場位,以實現浮動止損
maxhl:=l;
zs:=gbg;
end
if holding>0 and h>maxhl then begin //創新高后,重新定位離場位,以實現浮動止損
zs:=gbd;
maxhl:=h;
end
input:lots(1,0,100,1);
variable:N1=1;
i_offset:=N1*MINDIFF;
D1 := llv(REF(Low,2),22); //求1個月最低價
D2 := hhv(REF(High,2),22); //求1個月最高價
D3 := IntPart(0.008*ref(Open,1)); //昨日開盤價的0.8%
Condition1 := (REF(LOW,1)<=D1 OR REF(LOW,2)<=D1 OR REF(LOW,3)<=D1) And (REF(Open,1)-REF(CLOSE,1))>=D3; //判斷反轉日,由多轉空
Condition2 := (REF(HIGH,1)>=D2 OR REF(HIGH,2)<=D2 OR REF(HIGH,3)<=D2) And (REF(CLOSE,1)-REF(Open,1))>=D3; //判斷反轉日,由空轉多
if Condition2 then
begin
if holding=0 then
BEGIN
buy(1,lots,limitr,(Open+i_offset));
end
if holding<0 then
begin
SELLSHORT(1,0,limitr,(Open+i_offset));
buy(1,lots,limitr,(Open+i_offset));
end
end
if Condition1 then
begin
if holding=0 then
BEGIN
BUYSHORT(1,lots,limitr,(Open-i_offset));
end
if holding>0 then
begin
SELL(1,0,limitr,(Open-i_offset));
BUYSHORT(1,lots,limitr,(Open-i_offset));
end
end
//資產:asset,noaxis,colorred,linethick2;