哪位高人幫忙看一下吧 [金字塔]
- 咨詢內(nèi)容:
//定義n日平倉;
input:n(3,3,20,1);
//定義單日上漲或下跌百分比;
input:m(3,3,20,0.5);
input:posNum(1,1,20,1);
//變量定義
VARIABLE:position:=0;//倉位狀態(tài),0表示沒有持倉,1表示多頭,-1表示空頭
variable:barCount:=0;//記錄信號(hào)出現(xiàn)日是第幾根bar;
variable:lClosePrice:=0;//記錄信號(hào)出來前一日收盤價(jià);
variable:closePrice:=0;//記錄信號(hào)出來當(dāng)日收盤價(jià);
llastC:=ref(close,2);//前日收盤價(jià);
lastC:ref(close,1);//昨日收盤價(jià);
myExitPrice:=0;
//如果當(dāng)前沒有持倉
if(position=0) then begin
//多頭進(jìn)場(chǎng)條件
long :=((lastC-llastC)/llastC)>0.03;
l0:(lastC-llastC)/llastC,linethick0;
//多頭進(jìn)場(chǎng)
if long=1 then begin
myEntryPrice:=if(OPEN>lastC+MINDIFF,open,lastC+MINDIFF);//判斷跳空情況
buy(1,posNum,LIMITR,myEntryPrice);
position:=1;
barCount:=BARPOS-1;
lClosePrice:=llastC;//開倉時(shí)候記錄開倉前日收盤價(jià);
closePrice:=lastC;
end
end
p1:position,linethick0;
b:barCount,linethick0;
//有多頭倉位的情況,3種情況,止損平倉,定時(shí)平倉,持有后移動(dòng)止損獲利平倉;
if position=1 then BEGIN
//止損平倉
longX1:=low<(closePrice-(closePrice-lClosePrice)*0.65);//價(jià)格跌破信號(hào)出來時(shí)那一天長(zhǎng)陽線的65%;
l123:closePrice-(closePrice-lClosePrice)*0.65,linethick0;
if(longX1=1)then BEGIN //無論如何,會(huì)進(jìn)入,不知為何??????????????
myExitPrice:=if(open<closePrice-(closePrice-lClosePrice)*0.65,open,closePrice-(closePrice-lClosePrice)*0.65);
exitP:myExitPrice;
myExitPrice:=floor(myExitPrice/MINDIFF)*MINDIFF; //對(duì)齊到最小變動(dòng)價(jià)位;
sell(1,0,limitr,myExitPrice);//作為例子,使用限價(jià)指令,在圖上標(biāo)出;可以使用市價(jià)指令;
position:=0;
end//定時(shí)平倉
{ longX2:=low<(myEntryPrice-2*N);//myEntryPrice,不是局部變量嗎
if(longX2 and position=1)then BEGIN
myExitPrice:=if(open<myEntryPrice-2*N,open,myEntryPrice-2*N);
myExitPrice:=floor(myExitPrice/MINDIFF)*MINDIFF; //對(duì)齊到最小變動(dòng)價(jià)位;
sell(1,0,limitr,myExitPrice);//作為例子,使用限價(jià)指令,在圖上標(biāo)出;可以使用市價(jià)指令;
position:=0;
totolUnits:=0;
end}
end
p2:position,linethick0;下面那段平倉的代碼,怎么無論如何都會(huì)進(jìn)入?
- 金字塔客服:
還有,怎么公式調(diào)試器不好用啊,好奇怪,是因?yàn)槊赓M(fèi)版嗎
- 用戶回復(fù):
longX2 and position=1
這個(gè)平倉條件滿足后才能平倉,使用shift+q的調(diào)試功能,進(jìn)行調(diào)試,查看結(jié)果是否符合預(yù)期
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 511411198 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容