Re: [問題] MC回測取消STOP
※ 引述《hollejacklin (私は不器用です)》之銘言:
: 請問我在用MC做回測時
: 有一段語法是
: if condition then begin;
: buy 1 contract next bar at price stop;
: sellshort 1 contract next bar at price2 stop;
: end;
: 如果 next bar 波動太大 例如 open > price and low < price2
: 可是我的想法是 只要留多倉就好 不打算當天反手
: 那我要怎麼寫才可以取消空單的觸價單
: 謝謝各位解答
這一根 K 棒滿足條件的話下一根 K 棒一開始就會丟出兩張 Stop Order,
所以等跑到下一根 K 棒發現 Open 價遠超過觸價的話,
此時你已無法取消反向邊的 Stop Order。
如果你這個策略僅作為評估操作績效,而不會將它真正上線跑的話,
可以想辦法,在這一根 K 棒時就預先取得下一根 K 棒的開盤價:
if condition then
begin
if open_of_next_bar > price then
buy next bar at price stop
else if open_of_next_bar < price2 then
sellshort next bar at price2 stop
else
begin
buy next bar at price stop;
sellshort next bar at price2 stop;
end;
end;
寫個小程式,將下一根 K 的 Open 價導入變成一個外部資料,讓程式抓!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 180.176.137.188
討論串 (同標題文章)