利用上一篇文章的指標,相信可以觀察到
在比較強勢的盤,Highd(0)是一直在更新的
在明顯的跌勢也是,Lowd(0)也會一直更新
現在設計一個策略
只要line等於Highd(0)就在價格觸碰到line的時候做多一口
同理,line等於Lowd(0)時,就放空。
程式碼如下
vars:Line(0);
if date[0] < > date[1] and opend(0) > closed(1) then line = highd(0);
if date[0] < > date[1] and opend(0) < = closed(1) then line = lowd(0);
if date[0] = date[1] then begin
if H = highd(0) and L > lowd(0) then line = highd(0);
if L = lowd(0) and H < highd(0) then line = lowd(0);
end;
if line = highd(0) then buy next bar at line stop;
if line = lowd(0) then sell next bar at line stop;
回測如下
30K,成本1200