平仓信号满足,但没有在当根K线进行平仓

    苦行僧 发表于 2020-06-10 21:24 ・837次浏览 1条跟帖 赢智 wh8 回复

    刚刚我模组的平仓语句出了点问题,是这样的,在箭头所指的K线进行加仓了一次,后平仓条件也满足了,按逻辑也该在箭头所指K线平仓的,结果要到下一根K线才平仓我的模组是有单根K线多个信号函数的,怎么会到了下一根K线才平仓呢,是不是少了什么 brWpfbS36dSYXD6n.jpg
    MULTSIG(0,0,4,0);
    TR : MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
    ATR : MA(TR,26);
    TC..INTPART((10000*0.055/(UNIT*ATR*1.1)));
    HH:=HHV(H,20);
    LL:=LLV(L,20);
    MTC..SIGVOL(1)*2;
    C>=HH&&BARPOS>=20,BK(TC);
    C<=LL&&BARPOS>=20,SK(TC);
    
    BKB:=IF(COUNTSIG(BK,1)>0,0,BARSBK);
    SKB:=IF(COUNTSIG(SK,1)>0,0,BARSSK);
    BKVOL>0&&BKVOL<MTC&&C>=BKPRICE+1.1*REF(ATR,BKB),BK(BKVOL);
    BKVOL>0&&BKVOL<MTC&&C>=BKPRICE+1.1*ATR&&ISNULL(BKB),BK(BKVOL);
    SKVOL>0&&SKVOL<MTC&&C<=SKPRICE-1.1*REF(ATR,SKB),SK(SKVOL);
    SKVOL>0&&SKVOL<MTC&&C<=SKPRICE-1.1*ATR&&ISNULL(SKB),SK(SKVOL);
    C<=BKPRICE-1.1*REF(ATR,BKB),SP(BKVOL);
    C>=SKPRICE+1.1*REF(ATR,SKB),BP(SKVOL);
    C<=BKPRICE-1.1*ATR&&COUNTSIG(BK,1)=1,SP(BKVOL);
    C>=SKPRICE+1.1*ATR&&COUNTSIG(SK,1)=1,BP(SKVOL);
    EXIST(BKHIGH-BKPRICE>=1.1*REF(ATR,BKB),BKB)&&C-BKPRICE<=0*ATR&&EXIST(BKHIGH-BKPRICE>=2.1*REF(ATR,BKB),BKB)=0,SP(BKVOL);
    EXIST(SKPRICE-SKLOW>=1.1*REF(ATR,SKB),SKB)&&SKPRICE-C<=0*ATR&&EXIST(SKPRICE-SKLOW>=2.1*REF(ATR,SKB),SKB)=0,BP(SKVOL);
    EXIST(BKHIGH-BKPRICE>=2.2*REF(ATR,BKB),BKB)&&C-BKPRICE<=1.1*REF(ATR,BKB)&&EXIST(BKHIGH-BKPRICE>=3.2*REF(ATR,BKB),BKB)=0,SP(BKVOL);
    EXIST(SKPRICE-SKLOW>=2.2*REF(ATR,SKB),SKB)&&SKPRICE-C<=1.1*REF(ATR,SKB)&&EXIST(SKPRICE-SKLOW>=3.2*REF(ATR,SKB),SKB)=0,BP(SKVOL);
    EXIST(BKHIGH-BKPRICE>=3.3*REF(ATR,BKB),BKB)&&C<=BKHIGH-0.2*(BKHIGH-BKPRICE),SP(BKVOL);
    EXIST(SKPRICE-SKLOW>=3.3*REF(ATR,SKB),SKB)&&C>=SKLOW+0.2*(SKPRICE-SKLOW),BP(SKVOL);
    EXIST(BKHIGH-BKPRICE>=3.3*REF(ATR,BKB),BKB)&&BKHIGH-C>=1.7*REF(ATR,BKB),SP(BKVOL);
    EXIST(SKPRICE-SKLOW>=3.3*REF(ATR,SKB),SKB)&&C-SKLOW>=1.7*REF(ATR,SKB),BP(SKVOL);
    SETSIGPRICETYPE(BK, LIMIT_ORDER);
    SETSIGPRICETYPE(SK, LIMIT_ORDER);
    SETSIGPRICETYPE(SP,LIMIT_ORDER);
    SETSIGPRICETYPE(BP,LIMIT_ORDER);

       

    autojiaoyi.com 沙发

    BKB在当根K线有BK信号的时候取0,EXIST(X,0)求0周期是否存在X,结果是0,所以无法平仓
    
    这样改下看看:
    
    MULTSIG(0,0,4,0);
    TR : MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
    ATR : MA(TR,26);
    TC..INTPART((10000*0.055/(UNIT*ATR*1.1)));
    HH:=HHV(H,20);
    LL:=LLV(L,20);
    MTC..SIGVOL(1)*2;
    
    C>=HH&&BARPOS>=20,BK(TC);
    C<=LL&&BARPOS>=20,SK(TC);
    
    BKB:=IF(COUNTSIG(BK,1)>0,0,BARSBK);
    SKB:=IF(COUNTSIG(SK,1)>0,0,BARSSK);
    
    BKVOL>0&&BKVOL<MTC&&C>=BKPRICE+1.1*REF(ATR,BKB),BK(BKVOL);
    BKVOL>0&&BKVOL<MTC&&C>=BKPRICE+1.1*ATR&&ISNULL(BKB),BK(BKVOL);
    SKVOL>0&&SKVOL<MTC&&C<=SKPRICE-1.1*REF(ATR,SKB),SK(SKVOL);
    SKVOL>0&&SKVOL<MTC&&C<=SKPRICE-1.1*ATR&&ISNULL(SKB),SK(SKVOL);
    
    C<=BKPRICE-1.1*REF(ATR,BKB),SP(BKVOL);
    C>=SKPRICE+1.1*REF(ATR,SKB),BP(SKVOL);
    C<=BKPRICE-1.1*ATR&&COUNTSIG(BK,1)=1,SP(BKVOL);
    C>=SKPRICE+1.1*ATR&&COUNTSIG(SK,1)=1,BP(SKVOL);
    
    EXIST(BKHIGH-BKPRICE>=1.1*REF(ATR,BKB),BKB+1)&&C-BKPRICE<=0*ATR&&EXIST(BKHIGH-BKPRICE>=2.1*REF(ATR,BKB),BKB+1)=0,SP(BKVOL);
    EXIST(SKPRICE-SKLOW>=1.1*REF(ATR,SKB),SKB+1)&&SKPRICE-C<=0*ATR&&EXIST(SKPRICE-SKLOW>=2.1*REF(ATR,SKB),SKB+1)=0,BP(SKVOL);
    
    EXIST(BKHIGH-BKPRICE>=2.2*REF(ATR,BKB),BKB+1)&&C-BKPRICE<=1.1*REF(ATR,BKB)&&EXIST(BKHIGH-BKPRICE>=3.2*REF(ATR,BKB),BKB+1)=0,SP(BKVOL);
    EXIST(SKPRICE-SKLOW>=2.2*REF(ATR,SKB),SKB+1)&&SKPRICE-C<=1.1*REF(ATR,SKB)&&EXIST(SKPRICE-SKLOW>=3.2*REF(ATR,SKB),SKB+1)=0,BP(SKVOL);
    
    EXIST(BKHIGH-BKPRICE>=3.3*REF(ATR,BKB),BKB+1)&&C<=BKHIGH-0.2*(BKHIGH-BKPRICE),SP(BKVOL);
    EXIST(SKPRICE-SKLOW>=3.3*REF(ATR,SKB),SKB+1)&&C>=SKLOW+0.2*(SKPRICE-SKLOW),BP(SKVOL);
    
    EXIST(BKHIGH-BKPRICE>=3.3*REF(ATR,BKB),BKB)&&BKHIGH-C>=1.7*REF(ATR,BKB),SP(BKVOL);
    EXIST(SKPRICE-SKLOW>=3.3*REF(ATR,SKB),SKB)&&C-SKLOW>=1.7*REF(ATR,SKB),BP(SKVOL);
    
    SETSIGPRICETYPE(BK, LIMIT_ORDER);
    SETSIGPRICETYPE(SK, LIMIT_ORDER);
    SETSIGPRICETYPE(SP,LIMIT_ORDER);
    SETSIGPRICETYPE(BP,LIMIT_ORDER);
    回复

    本版积分规则

    发布新内容
    请关注微信公众号,获取最新指标公式
    加入收藏 我要分享
    分享到论坛或者博客

    复制
    热门指标策略
    快速回复 返回顶部 返回列表