請問后臺程式化策略用固定時間間隔模式如何實現(xiàn)K線走完再開倉?
作者:金字塔 來源:cxh99.com 發(fā)布時間:2016年07月13日
- 咨詢內(nèi)容:
我的策略平倉是用固定時間間隔模式,價格達到就止損。但是開倉需要K線走完再開,這個如何寫?
- 金字塔客服:
一般都是用ref的形式,比如你的開倉條件是c>o,那么就改成ref(c>o,1)
- 用戶回復:
比如下面的代碼如何改寫?if duo and islastbar then begin tbuy(1,手數(shù),mkt); endif kong and islastbar then begin tbuyshort(1,手數(shù),mkt); end if l<=tENTERPRICE-z*s and tENTERBARS>0 then begin tsell(1,手數(shù),mkt); end if h>=tENTERPRICE+z*s and tENTERBARS>0 then BEGINtsellshort(1,手數(shù),mkt); end
- 網(wǎng)友回復:
用ref(c>o,1)這種條件不能達到我的思路,我的意思是說,開倉是要等K線走完了,再開,平倉的話,只要條件達到,即時就平倉。這個能實現(xiàn)嗎?
- 網(wǎng)友回復:
或者說,模型是用K線走完模式,但是平倉需要用固定時間間隔模式,價格偏離成本一定波動就即時平倉,這個如何寫