value1=average(close,5);//5日均線
value2=average(close,10);//10日均線
value7=barslast(value1 cross over value2);//上次黃金交叉距今期數
variable: n(0);
variable: count(0);
variable:HH(0);
if close<value2 and value1>value2 then Begin //收盤小於10均
//執行迴圈,檢查過去黃金交叉有無破新高4次以內
HH=SimpleHighest(high,value7);
n=HighestBar(high,value7);
while n<value7 begin//以下的陳述(到end;為止),n=1執行一次,n=2執行一次,一直到n=剛黃金交叉
if HH>high[n+1]
then begin
count=count+1;
HH=high[n+1];
end;
n=n+1;
end;
//設定警示條件:if.. then ret=1;
if count<=4
then ret=1;
end;
2 評論