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

求指导平仓问题 [金字塔]

  • 咨询内容:


    设计一个逢低加仓模型,价格下降一个档位就加仓   加仓后如果上涨一个档位就把加仓的部分平掉???请问问题出在哪里呢



    H1:N+M;

    L1:N-M;

    A:=(H1-L1)/5;

    A1:L1+A;

    A2:L1+2*A;

    A3:L1+3*A;

    A4:L1+4*A;

    MA1:MA(C,10);

    手数:=1;

    CON1:= REF(MA1,1)>REF(A4,1) AND MA1<A4;   

    CON2:=REF(MA1,1)>REF(A3,1) AND MA1<A3;

    CON3:=REF(MA1,1)>REF(A2,1) AND MA1<A2;

    CON4:=REF(MA1,1)>REF(A1,1) AND MA1>A1;

    CON5:=REF(MA1,1)<REF(A4,1) AND MA1>A4;

    CON6: =REF(MA1,1)<REF(A3,1) AND MA1>A3;

    CON7: =REF(MA1,1)<REF(A2,1) AND MA1>A2;

    CON0: = H1-MA1<3 OR L-L1<3;

    IF CON1 AND HOLDING = 0 THEN BEGIN    //下穿A4

         BUY (1,手数, MARKET);

         END

        IF CON2 AND HOLDING  =1 THEN BEGIN     //下穿A3JIA

            BUY (1,手数, MARKET);

            END

        IF CON3 AND HOLDING =2 THEN BEGIN      //A2JIA

         BUY (1,手数, MARKET);

         END

        IF CON4 AND HOLDING = 3 THEN BEGIN       //A1JIA

          BUY (1,手数, MARKET);

          END

          

      IF CON7 AND HOLDING = 4 THEN BEGIN            //A2 --

           SELL(1,手数,MARKET);

           END

      IF CON6 AND HOLDING = 3 THEN BEGIN                   //A3--

          SELL(1,手数,MARKET);

           END

      IF CON5 AND HOLDING = 2 THEN BEGIN                      //A4--

           SELL(1,手数,MARKET);

          END

     

     IF CON2 AND HOLDING = 0 THEN BEGIN      //下穿A3

          BUY (1,手数, MARKET);

          

          IF CON3 AND HOLDING = 1 THEN BEGIN         //下穿A2加仓

               BUY (1,手数, MARKET);

               END

           IF CON6 AND HOLDING = 2 THEN BEGIN

                    SELL(1,手数,MARKET);

                 END

               

            IF CON4 AND HOLDING = 2 THEN BEGIN          //下穿A1加仓

                 BUY (1,手数, MARKET);

                 END

            IF CON7 AND HOLDING = 3 THEN BEGIN

                       SELL(1,手数,MARKET);

                  END          

      END           

    IF CON3 AND HOLDING = O THEN BEGIN       //下穿A2

             BUY (1,手数, MARKET);

     

         

       IF CON4 AND HOLDING = 1 THEN BEGIN       //下穿A1 加仓

           BUY (1,手数, MARKET);

           END

           IF CON7 AND HOLDING =2 THEN BEGIN         //上穿A2减仓

                 SELL(1,手数,MARKET);

                 

                 END

           

    END

     

     

     

             

     IF CON4 AND HOLDING = 0 THEN BEGIN    //下穿A1

        BUY (1,手数, MARKET);

        END

     

  • 金字塔客服:

    CON1:REF(MA1,1)>REF(A4,1) AND MA1<A4;   

    CON2:REF(MA1,1)>REF(A3,1) AND MA1<A3;

    CON3:REF(MA1,1)>REF(A2,1) AND MA1<A2;

    输出对饮条件,然后调试看下问题

 

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

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


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

相关文章

    没有相关内容