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