【MC8.5】同一個出場語句可分批出場
作者:MC 來源:cxh99.com 發布時間:2014年09月13日
- 咨詢內容:
本帖最后由 MC_Winnie 于 2013-10-11 16:21 編輯
同一個出場語句可分批出場
MC8.5新增語法,允許在一個進場后,一行出場語句在多次滿足條件時,分多次出場。
關鍵字:
SameExitFromOneEntryOnce
說明:
允許或禁止信號腳本,使用一行出場語句,從相同的進場執行多次分批出場。
用法:
[SameExitFromOneEntryOnce = LogicalValue]
參數:
LogicalValue —— True = 禁止分批出場;False = 允許分批出場。
注意:
在策略運行時,改變參數,不能編譯。
舉例:
若進場15手,分3次出場時,可以使用如下兩種代碼中的一種:
1)寫3個相同的出場語句- sellshort 15 contracts next bar at market;
- if marketposition<>0 then begin
- if (time = 1000) then buytocover (\"BC1\") 5 contracts next bar at entryprice-10 stop;
- if (time = 1001) then buytocover (\"BC2\") 5 contracts next bar at entryprice-10 stop;
- if (time = 1002) then buytocover (\"BC3\") 5 contracts next bar at entryprice-10 stop;
- end;
復制代碼2)使用SameExitFromOneEntryOnce,只寫一個出場語句
~此方法減少了代碼的冗余,增加閱讀性~- sellshort 15 contracts next bar at market;
- [SameExitFromOneEntryOnce = false]
- if marketposition<>0 then
- if (time = 1000) then buytocover (\"BC1\") 5 contracts next bar at entryprice-10 stop;
復制代碼
- MC技術部:
學習了