想要把多個策略寫在一起,會用到開平倉歷時函數,但組合在一起需要各個策略各自計算自己的開平倉歷時,自己怎么用代碼來表示enterbars和exitbars呢?
謝謝!
我自己寫了下列代碼,就是不行:
phold:=ref(hold,1); //hold
r10:BARSLAST(phold=0 and hold<>0),LINETHICK0;//開倉歷時
er10:BARSLAST(phold<>0 and hold=0),LINETHICK0;//平倉歷時
hold是這么計算的:
if 平多 and phold>0 then hold:=0;
if 平空 and phold<0 then hold:=0;
if 開多 and phold=0 then hold:=1;
if 開空 and phold=0 then hold:=-1;
請問,有什么問題嗎?
可以,將你的hold定義為一個全局變量
先用兩個策略組合起來嘗試
可以,將你的hold定義為一個全局變量
先用兩個策略組合起來嘗試
不行啊,開倉歷時和平倉歷時就是不正確啊!!
組合在一起,各個策略就無法用到enterbars了