hoishing 發表於 20-8-13 12:25

如何防止 stop order 在同一根K棒內 buy 和 sell

我在寫一個簡單的突破策略,如果突破前兩根 k 的高點便做多,突破低點便做空

buy next bar highest(h, 2) + 1 point stop;
sell next bar lowest(l, 2) + 1 point stop;

發現如果第三根的 h 比前兩根的更高,而且 l 比低點更低,第三根K 便會同時出現 buy 和 sell 的訊號,請問如何防止同一根K 棒出現兩個訊號呢?

其實我也想過不用 stop, 改寫成:

if close > highest(h, 2) then buy next bar market;
if close < lowest(l, 2) then sellshort next bar market;

但這樣訊號便會出現在第4根K或之後,如果我想訊號最早出現在第三根K棒,有什麼辦法呢?

沒房子的阿捨 發表於 20-8-25 00:08

if marketposition<> 1 then buy next bar highest(h, 2) + 1 point stop;
if marketposition<> -1 then sellshort next bar lowest(l, 2) + 1 point stop;
頁: [1]
查看完整版本: 如何防止 stop order 在同一根K棒內 buy 和 sell