請問此種離場方式如何設置?
作者:金字塔 來源:cxh99.com 發(fā)布時間:2017年10月03日
-
咨詢內(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日均線
a1:=0.01*valuewhen(barpos=1,asset); ? ? ? ? ? ? ?//初始資金的1%
a2:=floor(a1/(2*atr)); ? ? ? ? ? ? ? ? ? ? ? ? //開倉手數(shù)
a3:=ref(hhv(high,20),1); ? ? ? ? ? ? ? ? ? ? ? //20日高點
if holding=0 and close>a3 and close>ma20 and bj=0
then begin
buy(1,a2,marketr);
bj:=1;
end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //第一次開倉
a4:=enterprice+2*atr;
if holding=0 and close>a4 and bj=1?
then begin
buy(1,a2,marketr);
end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//第n次開倉
a5:=enterprice-2*ref(atr,enterbars=1);
if holding=1 and low<=a5
then begin
sell(1,0,limitr,a4);
end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //第一次開倉的離場?
現(xiàn)在,我要設置的、當holding>1時的離場方式為:收盤<("holding=n"與“holding=n-1”)/2的位置;請問該如何編寫?
此主題相關圖片如下:止損.jpg
[此貼子已經(jīng)被作者于2017/3/22 11:27:39編輯過]
?
-
金字塔客服:
http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=149324&page=2