為什么會偶爾出現(xiàn)該加倉卻不加倉的問題 [金字塔]
- 咨詢內(nèi)容:
//聲明變量
//調(diào)試信息帶時間戳BBAR := 0 ;
//當前BAR有過交易
VARIABLE : _DEBUG = 1 ; //是否輸出前臺交易指令VARIABLE : _TDEBUG = 1 ; //是否輸出后臺交易指令VARIABLE : _DEBUGOUT = 0 ; //是否輸出后臺交易的調(diào)試信息
VARIABLE : MYENTRYPRICE =0 ; //開倉價格VARIABLE : MYEXITPRICE =0 ; //平倉價格
VARIABLE : TURTLEUNITS=0 ; //交易單位VARIABLE : POSITION=0 ; //倉位狀態(tài)//0表示沒有倉位,1表示持有多頭, -1表示持有空頭
.......
LK2:=NUMPROFIT(1 )<0 AND NUMPROFIT(2 )<0 ;
KD:=REF(C,1)>REF(H2,1); //開多條件PD:=REF(C,1)<REF(L2,1); //平多條件KK:=REF(C,1)<REF(L2,1); //開空條件PK:=REF(C,1)>REF(H2,1); //平空條件
//開始執(zhí)行時 初始化數(shù)據(jù)IF BARPOS=1 THEN BEGIN //POSITION := 0 ;
END //IF
//如果當前是沒有持倉的狀態(tài)IF POSITION=0 THEN BEGIN
//建立多頭進場條件 LONG :=KD; //多頭進場 IF LONG AND POSITION=0 AND BBAR=0 THEN BEGIN BJ:=IF(C<=DYNAINFO( 28),C,C-1*MINDIFF); SJ:=IF(C>=DYNAINFO( 34),C,C+1*MINDIFF); BUY(LONG,SS,LIMITR,BJ),IGNORECHECKPRICE; POSITION := 1 ; TURTLEUNITS := 1 ; BBAR := 1;
END //IF
//建立空頭進場條件 SHORT :=KK ; //空頭進場 IF SHORT AND POSITION=0 AND BBAR=0 THEN BEGIN BJ:=IF(C<=DYNAINFO( 28),C,C-1*MINDIFF); SJ:=IF(C>=DYNAINFO( 34),C,C+1*MINDIFF); BUYSHORT(SHORT,SS,LIMITR,SJ),IGNORECHECKPRICE; POSITION := -1 ; TURTLEUNITS := 1 ; BBAR := 1;
END //不要跳轉(zhuǎn),讓程序檢查同一根K線是否可以加倉 //GOTO CONTINUELINE ; END //IF
//如果當前持有多頭倉位的狀態(tài)
IF POSITION=1 AND BBAR=0 THEN BEGIN
//多頭加倉條件 WHILE LK2 AND CC>ENTERPRICE+0.5*N AND TURTLEUNITS<3 AND BBAR=0 DO BEGIN BJ:=IF(C<=DYNAINFO( 28),C,C-1*MINDIFF); SJ:=IF(C>=DYNAINFO( 34),C,C+1*MINDIFF); BUY( LK2 AND CC>ENTERPRICE+0.5*N AND TURTLEUNITS<3,SS,LIMITR,BJ ),IGNORECHECKPRICE; TURTLEUNITS := TURTLEUNITS+1 ; BBAR := 1;
END //WHILE //建立多頭離場條件 LONGX1 := PD ; IF LONGX1 AND POSITION=1 AND BBAR=0 THEN BEGIN BJ:=IF(C<=DYNAINFO( 28),C,C-1*MINDIFF); SJ:=IF(C>=DYNAINFO( 34),C,C+1*MINDIFF); SELL( LONGX1 ,100%,LIMITR,SJ),IGNORECHECKPRICE; POSITION := 0 ; TURTLEUNITS := 0 ; BBAR := 1; END
//建立多頭止損條件 LONGX2 := (CC<ENTERPRICE-3*N) ;
IF LONGX2 AND POSITION=1 AND BBAR=0 THEN BEGIN BJ:=IF(C<=DYNAINFO( 28),C,C-1*MINDIFF); SJ:=IF(C>=DYNAINFO( 34),C,C+1*MINDIFF); SELL( LONGX2 ,100%,LIMITR,SJ),IGNORECHECKPRICE; POSITION := 0 ; TURTLEUNITS := 0 ; BBAR := 1; END
END //IF
//如果當前持有空頭倉位的狀態(tài)
IF POSITION = -1 AND BBAR=0 THEN BEGIN
//空頭加倉條件 WHILE LK2 AND CC<ENTERPRICE-0.5*N AND TURTLEUNITS<3 AND BBAR=0 DO BEGIN BJ:=IF(C<=DYNAINFO( 28),C,C-1*MINDIFF); SJ:=IF(C>=DYNAINFO( 34),C,C+1*MINDIFF); BUYSHORT(LK2 AND CC<ENTERPRICE-0.5*N AND TURTLEUNITS<3,SS, LIMITR,SJ),IGNORECHECKPRICE; TURTLEUNITS := TURTLEUNITS+1 ; BBAR := 1; END //IF
//建立空頭離場條件 SHORTX1 := PK ;
IF SHORTX1 AND BBAR=0 THEN BEGIN BJ:=IF(C<=DYNAINFO( 28),C,C-1*MINDIFF); SJ:=IF(C>=DYNAINFO( 34),C,C+1*MINDIFF); SELLSHORT( SHORTX1,100%,LIMITR,BJ),IGNORECHECKPRICE; POSITION := 0 ; TURTLEUNITS := 0 ; BBAR := 1; END
//建立空頭止損條件 SHORTX2 :=( CC >ENTERPRICE + 3*N) ;
IF SHORTX2 AND POSITION = -1 AND BBAR=0 THEN BEGIN BJ:=IF(C<=DYNAINFO( 28),C,C-1*MINDIFF); SJ:=IF(C>=DYNAINFO( 34),C,C+1*MINDIFF); SELLSHORT( SHORTX2,100%,LIMITR,BJ),IGNORECHECKPRICE; POSITION := 0 ; TURTLEUNITS := 0 ; BBAR := 1; END
END //IF
//顯示賬戶狀態(tài)
持倉:HOLDING,COLORWHITE,LINETHICK0; - 金字塔客服:
請具體指出哪根k線上是“應該加倉卻不加倉”的?
還有DYNAINFO( 34)這個動態(tài)行情函數(shù)不要用在圖表交易上,會造成信號的消失,影響當前信號的出現(xiàn)
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 511411198 進行 有償 編寫!(不貴!點擊查看價格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容