您现在的位置:程序化交易>> 期货公式>> 金字塔等>> 金字塔知识>>正文内容

为什么会偶尔出现该加仓却不加仓的问题 [金字塔]

  • 咨询内容: //声明变量 //调试信息带时间戳BBAR := 0 ; //当前BAR有过交易
    VARIABLE : _DEBUG = 1 ; //是否输出前台交易指令VARIABLE : _TDEBUG = 1 ; //是否输出后台交易指令VARIABLE : _DEBUGOUT = 0 ; //是否输出后台交易的调试信息
    VARIABLE : MYENTRYPRICE =0 ; //开仓价格VARIABLE : MYEXITPRICE =0 ; //平仓价格
    VARIABLE : TURTLEUNITS=0 ; //交易单位VARIABLE : POSITION=0 ; //仓位状态//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);           //平空条件

     //开始执行时 初始化数据IF BARPOS=1 THEN BEGIN //POSITION := 0 ;
    END //IF
    //如果当前是没有持仓的状态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 //不要跳转,让程序检查同一根K线是否可以加仓 //GOTO CONTINUELINE ; END  //IF

    //如果当前持有多头仓位的状态
    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

    //如果当前持有空头仓位的状态
    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

    //显示账户状态

    持仓:HOLDING,COLORWHITE,LINETHICK0;

     

  • 金字塔客服:

    请具体指出哪根k线上是“应该加仓却不加仓”的?

    还有DYNAINFO( 34)这个动态行情函数不要用在图表交易上,会造成信号的消失,影响当前信号的出现

 

有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友

可联系技术人员 QQ: 511411198  点击这里给我发消息进行 有偿 编写!不贵!点击查看价格!


【字体: 】【打印文章】【查看评论

相关文章

    没有相关内容