請(qǐng)問(wèn)此種離場(chǎng)方式如何設(shè)置? [金字塔]
-
咨詢(xún)內(nèi)容:
代碼如下:
variable:bj=0; tr1 : max(max((high-low),abs(ref(close,1)-high)),abs(ref(close,1)-low)); atr : ma(tr1,20); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //atr公式
ma20:ma(close,20); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //20日均線(xiàn)
a1:=0.01*valuewhen(barpos=1,asset); ? ? ? ? ? ? ?//初始資金的1%
a2:=floor(a1/(2*atr)); ? ? ? ? ? ? ? ? ? ? ? ? //開(kāi)倉(cāng)手?jǐn)?shù)
a3:=ref(hhv(high,20),1); ? ? ? ? ? ? ? ? ? ? ? //20日高點(diǎn)
if holding=0 and close>a3 and close>ma20 and bj=0 then begin buy(1,a2,marketr); bj:=1; end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //第一次開(kāi)倉(cāng)
a4:=enterprice+2*atr; if holding=0 and close>a4 and bj=1? then begin buy(1,a2,marketr); end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//第n次開(kāi)倉(cāng)
a5:=enterprice-2*ref(atr,enterbars=1); if holding=1 and low<=a5 then begin sell(1,0,limitr,a4); end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //第一次開(kāi)倉(cāng)的離場(chǎng)?
現(xiàn)在,我要設(shè)置的、當(dāng)holding>1時(shí)的離場(chǎng)方式為:收盤(pán)<("holding=n"與“holding=n-1”)/2的位置;請(qǐng)問(wèn)該如何編寫(xiě)?
此主題相關(guān)圖片如下:止損.jpg
[此貼子已經(jīng)被作者于2017/3/22 11:27:39編輯過(guò)]?
- 金字塔客服: http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=149324&page=2
有思路,想編寫(xiě)各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 511411198 進(jìn)行 有償 編寫(xiě)!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容