设为首页收藏本站

 找回密码
 注册
楼主: TradeStar
打印 上一主题 下一主题

哥哥姐姐们,怎么实现连续亏损N次后加仓啊: [复制链接]

Rank: 2

精华
0
UID
1928
积分
115
帖子
12
主题
4
阅读权限
30
注册时间
2008-7-18
最后登录
2019-3-31
11#
发表于 2008-8-21 17:09:16 |只看该作者
请帮忙看看下面这个模板哪里出了问题:
Params
       
        Numeric BuyLots(1);
        Numeric SellLots(1);
Vars
    NumericSeries conFailureCnt(0);
    Numericseries X;
        Bool Condition1;
        Bool Condition2;
        Bool Condition3;
        Bool Condition4;
Begin
    If(BarStatus==0)
    {
        conFailureCnt = 0;
    }else
    {
        conFailureCnt = conFailureCnt[1];
    }

    Condition1 =
        Condition2 =
    Condition3 =
    Condition4 =
                        X  = 500

    if (Condition1 && Condition3 &&  MarketPosition == 0)
          {
                Buy(BuyLots,Close,true);
          }
        if (marketposition == 1)
          {
          If(conFailureCnt == 1)
                    {
                         Buy(BuyLots,Close,true);
                           }
                If(conFailureCnt == 2)
                    {
                         Buy(BuyLots,Close,true);
                           }
         If(conFailureCnt == 3)
                    {
                         Buy(BuyLots,Close,true);
                           }
           }
        if (Condition2)
          {
                Sell(0,close,true);
         conFailureCnt = 0;
          }



        if (Condition2 && Condition4 &&  MarketPosition == 0)
          {
                SellShort(SellLots,Close,true);
          }
        if (marketposition == -1)
      {
           If(conFailureCnt == 1)
                                {
                          SellShort(SellLots,Close,true);
                                 }
             If(conFailureCnt == 2)
                                {
                          SellShort(SellLots,Close,true);
                                 }
             If(conFailureCnt == 3)
                                {
                          SellShort(SellLots,Close,true);
                                 }         
        }   
        if (Condition1)
          {
                BuyToCover(0,close,true);
                conFailureCnt = 0;      
          }


    If(MarketPosition <>0 )
    {
           If(ContractProfit > X)
           {
                 conFailureCnt = conFailureCnt  + 1;
            }
    }




End
我的设想是持仓后,每手盈利一超过X就加一仓,因为加了仓后每手盈利会降低,所以再次每手盈利达到X的时候,又可以加一手,不论多空.可是按照我这程序,执行的时候多单胡乱加仓,不管盈亏,空单从不加仓

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-19 13:36

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部