關(guān)于平倉判斷成交后再開倉的反手指令,金字塔的解決方案和TB的不作為比較!
作者:開拓者 TB 來源:cxh99.com 發(fā)布時(shí)間:2013年01月27日
- 咨詢內(nèi)容: 日內(nèi)滿倉交易時(shí),平倉反手的實(shí)現(xiàn)方法 Post By:2011-7-13 22:43:44 [只看該作者]
日內(nèi)滿倉交易時(shí),平倉反手的時(shí)候,有個(gè)問題要特別注意,就是在平倉單未成交前如果發(fā)出開倉委托單會(huì)出現(xiàn)保證金不足的情況造成無法自動(dòng)開倉
這個(gè)問題是眾所周知的
1,一般的處理方法是在每個(gè)下單指令的最后面加一個(gè)順序下單控制符,如下:
hi:=ref(hhv(h,20),1);
lo:=ref(llv(l,20),1);
entertime:=time<=144500;
exittime:=time>=145700;
buycond:=c>hi;
sellcond:=c<lo;
if holding>0 and (sellcond or exittime) then sell(1,1,market),orderqueue;
if holding<0 and (buycond or exittime) then sellshort(1,1,market),orderqueue;
if holding=0 and entertime and buycond then buy(1,1,market),orderqueue;
if holding=0 and entertime and sellcond then buyshort(1,1,market),orderqueue;
這種方法基本上可以解決問題。orderqueue順序下單的意思是委托單按先后順序排隊(duì)等待,依次處理
但也有不足的地方,就是在平倉單未及時(shí)成交時(shí),依然會(huì)出現(xiàn)保證金不足的錯(cuò)誤。如 A(平多)、B(開空),A未及時(shí)成交自動(dòng)撤單后追單
自動(dòng)追單的委托就排在后面了,也就是下單順序就為 B、A 。B發(fā)送時(shí)就會(huì)提示錯(cuò)誤,因?yàn)楸WC金并未釋放。
2,現(xiàn)提出另一處理方法
問題的關(guān)鍵,就是要等平倉單完全成交后再發(fā)開倉單,這樣才能避免出現(xiàn)保證金不足的情況
反手模型有個(gè)特點(diǎn),就是平倉單成交后,倉位為0,而后臺(tái)的tholding2這個(gè)函數(shù)就是表示實(shí)際持倉
于是:
hi:=ref(hhv(h,20),1);
lo:=ref(llv(l,20),1);
entertime:=time<=144500;
exittime:=time>=145700;
buycond:=ref(c>hi,1);
sellcond:=ref(c<lo,1);
abb:=not(islastbar) or (islastbar and tholding2=0);//這里要這樣處理,否則tholding2會(huì)影響前面得信號(hào)
if holding>0 and (sellcond or exittime) then sell(1,1,market);
if holding<0 and (buycond or exittime) then sellshort(1,1,market);
if holding=0 and entertime and buycond and abb then buy(1,1,market);
if holding=0 and entertime and sellcond and abb then buyshort(1,1,market);
程序執(zhí)行過程:1,平倉單發(fā)出后,不發(fā)開倉單,因?yàn)閠holding2不為0.如果平倉單沒及時(shí)成交,自動(dòng)撤單后追單直至成交
2,平倉單成交后,tholding2=0,此時(shí)開倉指令條件成立,發(fā)出開倉單。不會(huì)出現(xiàn)保證金不足的情況
3,注意,用的是tholding2,而非tholding,tholding會(huì)受未成交委托單影響。
以上適用的條件 :1,需要平倉委托在信號(hào)成立的K線內(nèi)成交,才能發(fā)出開倉委托。模型基本符合這個(gè)條件
2,固定時(shí)間間隔或者高頻。如果是K線走完模式,還需稍作修改為固定時(shí)間間隔模式
注:這么重要的功能,TB到現(xiàn)在也沒有一個(gè)成功的事例來給初級(jí)投資者一個(gè)模板,來幫助我們這些初級(jí)學(xué)者來實(shí)現(xiàn)這種重要的功能,不知道TB整天都在干什么?
- TB技術(shù)人員: TB公式里指南里有現(xiàn)成的平倉延遲5個(gè)TICK反手的模板。
請(qǐng)查閱