MC回測取消STOP - 財經

Elvira avatar
By Elvira
at 2011-06-10T16:22

Table of Contents

※ 引述《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 價導入變成一個外部資料,讓程式抓!

--
Tags: 財經

All Comments

MC回測取消STOP

Sandy avatar
By Sandy
at 2011-06-06T18:36
※ 引述《hollejacklin (私は不器用です)》之銘言: 請問我在用MC做回測時 有一段語法是 if condition then begin; buy 1 contract next bar at price stop; sellshort 1 contract ...

MC回測取消STOP

Faithe avatar
By Faithe
at 2011-06-05T00:52
請問我在用MC做回測時 有一段語法是 if condition then begin; buy 1 contract next bar at price stop; sellshort 1 contract next bar at price2 stop; end; 如果 ...

市場真的就這樣??!!

Aaliyah avatar
By Aaliyah
at 2011-06-03T20:36
※ 引述《yuting0103 (凌波微步)》之銘言: : ※ 引述《miky (四辦幸運草)》之銘言: : : 我是寫mt4程式的新手 : : 因為還不太會寫ea : : 結果還沒把自己的策略寫出來 : : 卻寫出了一個傻眼的結果 : : 策略只有兩點 : : 1.只設移動停損,沒有止損止盈 : : 2.只 ...

市場真的就這樣??!!

Harry avatar
By Harry
at 2011-06-03T02:55
※ 引述《KZHenry (在時光中飛舞)》之銘言: : ※ 引述《miky (四辦幸運草)》之銘言: : : 我是寫mt4程式的新手 : : 因為還不太會寫ea : : 結果還沒把自己的策略寫出來 : : 卻寫出了一個傻眼的結果 : : 策略只有兩點 : : 1.只設移動停損,沒有止損止盈 : : 2.只要 ...

市場真的就這樣??!!

Barb Cronin avatar
By Barb Cronin
at 2011-06-02T22:34
※ 引述《miky (四辦幸運草)》之銘言: : 我是寫mt4程式的新手 : 因為還不太會寫ea : 結果還沒把自己的策略寫出來 : 卻寫出了一個傻眼的結果 : 策略只有兩點 : 1.只設移動停損,沒有止損止盈 : 2.只要一停損,馬上反向操作 : 這樣的結果就會一直在市場中 : 本來以為回測會一下就賠光 : ...