设为首页收藏本站

 找回密码
 注册
查看: 2727|回复: 7
打印 上一主题 下一主题

菜鸟求助如何实现回调30%减仓?谢谢大家。 [复制链接]

Rank: 1

精华
0
UID
168984
积分
16
帖子
4
主题
2
阅读权限
10
注册时间
2013-8-15
最后登录
2013-8-27
跳转到指定楼层
1#
发表于 2013-8-27 08:30:16 |只看该作者 |倒序浏览
先上公式,
//------------------------------------------------------------------------
// 简称: test2
// 名称: test2
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------
Params
        Numeric length1(55);
    Numeric length2(8);       
        Numeric length3(0.3);
Vars
    Bool pdH;
        Bool pdL;
        Bool pdjianduo(False);
        Bool pdjiankong(False);
        Numeric closeh;
        Numeric closel;
        Numeric shuju;
        Numeric shujuH;
        Numeric shujuL;
        Numeric price;
    Numeric buypos;
        Numeric buymax;
        Numeric sellmax;
    Numeric jianduoline;
        Numeric jiankongline;
        Numeric jiancangwei;
        Numeric n(1);

       
Begin
    PlotString("CurrentBar",Text(CurrentBar));
    price=AvgEntryPrice;
    buypos=Abs(MarketPosition);
        PlotNumeric("ma1",Average(close,length1));
        PlotNumeric("ma1+Close*0.005",Average(close,length1)+Close*0.005);
        PlotNumeric("ma1-Close*0.005",Average(close,length1)-Close*0.005);
        shuju=Average(close,length1);
        shujuH=Average(close,length1)+Close*0.005;
        shujuL=Average(close,length1)-Close*0.005;
        pdH=Close>Highest(Close[1],15);
        pdL=Close<Lowest(Close[1],15);
        If(pdH==True)
      {
          closeh=close;
          PlotString("Text","高点",High,Yellow);
          }
          
        If(pdL==True)
          {
           closel=close;
           PlotString("Text","低点",Low,Yellow);
          }
        buymax=closeh-price;
        sellmax=price-closel;
        jianduoline=price+(buymax*0.7);
        jiankongline=price-(sellmax*0.7);
        pdjianduo=Close<jianduoline;
        pdjiankong=Close>jiankongline;
        jiancangwei=IntPart(length3*buypos);
       
               
        If(Close[1]>shujuH && open>shuju && MarketPosition<=0)
              {
                    if(MarketPosition<>0)
                        BuyToCover(0,Open);
                Buy(0,Open);
                       
                  }
                  
        If(Close[1]<shujuL && open<shuju && MarketPosition>=0)
                  {
                    if(MarketPosition<>0)
                        Sell(0,Open);
                        SellShort(0,Open);
                       
                  }
       
        If(MarketPosition>0 && CurrentBar>n*length2+length1 && CurrentBar<(n+1)*length2+length1)
                  {
                    if(pdjianduo==True )
                        {
                    Sell(jiancangwei,Open);
                        n=n+1;
                        }
                       
                  }
        If(MarketPosition<0 && CurrentBar>=n*length2+length1 && CurrentBar<=(n+1)*length2+length1)
                  {
                    if(pdjiankong==true)
                        {
                    BuyToCover(jiancangwei,Open);
                        n=n+1;
                        }
                       
                  }
       
                  
        End
               


//------------------------------------------------------------------------
// 编译版本        GS2010.12.08
// 用户版本        2013/08/26 09:30
// 版权所有        testone
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------



减仓的思路是出现最大收盘价利润后,收盘价回调30%减仓。length1(均线周期) length2(减仓周期)length3(减仓比例)。
公式的减仓部分没有办法执行,求各位老鸟指点一下。

Rank: 1

精华
0
UID
168984
积分
16
帖子
4
主题
2
阅读权限
10
注册时间
2013-8-15
最后登录
2013-8-27
2#
发表于 2013-8-27 08:30:46 |只看该作者
求助求助。

使用道具 举报

Rank: 1

精华
0
UID
170989
积分
37
帖子
30
主题
6
阅读权限
10
注册时间
1970-1-1
最后登录
2014-6-6
3#
发表于 2013-8-27 12:25:44 |只看该作者
这里应该是有逻辑的问题吧? If(Close[1]>shujuH && open>shuju && MarketPosition<=0)
              {
                    if(MarketPosition<>0)
                        BuyToCover(0,Open);
                Buy(0,Open);
                        
                  }
                  
上面是没仓位,下面又是有仓位。。。

使用道具 举报

Rank: 1

精华
0
UID
170989
积分
37
帖子
30
主题
6
阅读权限
10
注册时间
1970-1-1
最后登录
2014-6-6
4#
发表于 2013-8-27 12:58:20 |只看该作者
可以这样获利:Params
        Numeric length1(55);
    Numeric length2(8);        
        Numeric length3(0.3);
Vars
    Bool pdH;
        Bool pdL;
        Bool pdjianduo(False);
        Bool pdjiankong(False);
        Numeric closeh;
        Numeric closel;
        NumericSeries shuju;
        NumericSeries shujuH;
        NumericSeries shujuL;
        Numeric price;
    Numeric buypos;
        Numeric buymax;
        Numeric sellmax;
    Numeric jianduoline;
        Numeric jiankongline;
        Numeric jiancangwei;
        Numeric n(1);

        
Begin
    PlotString("CurrentBar",Text(CurrentBar));
    price=AvgEntryPrice;
    buypos=Abs(MarketPosition);
        PlotNumeric("ma1",Average(close,length1));
        PlotNumeric("ma1+Close*0.005",Average(close,length1)+Close*0.005);
        PlotNumeric("ma1-Close*0.005",Average(close,length1)-Close*0.005);
        shuju=Average(close,length1);
        shujuH=Average(close,length1)+Close*0.005;
        shujuL=Average(close,length1)-Close*0.005;
        pdH=Close>Highest(Close[1],15);
        pdL=Close<Lowest(Close[1],15);
        If(pdH==True)
      {
          closeh=close;
          PlotString("Text","高点",High,Yellow);
          }
           
        If(pdL==True)
          {
           closel=close;
           PlotString("Text","低点",Low,Yellow);
          }
        buymax=closeh-price;
        sellmax=price-closel;
        jianduoline=price+(buymax*0.7);
        jiankongline=price-(sellmax*0.7);
        pdjianduo=Close<jianduoline;
        pdjiankong=Close>jiankongline;
        jiancangwei=IntPart(length3*buypos);
        
               
        If(Close[1]>shujuH && open>shuju && MarketPosition<=0)
              {
                    if(MarketPosition<>0)
                        BuyToCover(0,Open);
                Buy(0,Open);
                        
                  }
                  
        If(Close[1]<shujuL && open<shuju && MarketPosition>=0)
                  {
                    if(MarketPosition<>0)
                        Sell(0,Open);
                        SellShort(0,Open);
                        
                  }
        
        If(MarketPosition>0 && CurrentBar>n*length2+length1 && CurrentBar<(n+1)*length2+length1)
                  {
                    if(pdjianduo==True )
                        {
                    Sell(jiancangwei,Open);
                        n=n+1;
                        }
                        
                  }
        If(MarketPosition<0 && CurrentBar>=n*length2+length1 && CurrentBar<=(n+1)*length2+length1)
                  {
                    if(pdjiankong==true)
                        {
                    BuyToCover(jiancangwei,Open);
                        n=n+1;
                        }
                        
                  }
        
     If(MarketPosition==1 && close[1]<shujuH[1]&& BarsSinceLastEntry>5)
             {
                   Sell(0,Open);
                  
             }
          If(MarketPosition==-1 && close[1]>shujuL[1]&& BarsSinceLastEntry>5)
             {
                   BuyToCover(0,Open);
                  
             }
        End

使用道具 举报

Rank: 1

精华
0
UID
170989
积分
37
帖子
30
主题
6
阅读权限
10
注册时间
1970-1-1
最后登录
2014-6-6
5#
发表于 2013-8-27 17:54:26 |只看该作者
你原来的有未来数据,应该改成下面那样,用在30分钟rb888可以有几万:Params
        Numeric length1(55);
    Numeric length2(8);        
        Numeric length3(0.3);
                       Numeric K5(5);
Vars
    Bool pdH;
        Bool pdL;
        Bool pdjianduo(False);
        Bool pdjiankong(False);
        Numeric closeh;
        Numeric closel;
        NumericSeries shuju;
        NumericSeries shujuH;
        NumericSeries shujuL;
        Numeric price;
    Numeric buypos;
        Numeric buymax;
        Numeric sellmax;
    Numeric jianduoline;
        Numeric jiankongline;
        Numeric jiancangwei;
        Numeric n(1);

        
Begin
    PlotString("CurrentBar",Text(CurrentBar));
    price=AvgEntryPrice;
    buypos=Abs(MarketPosition);
        PlotNumeric("ma1",Average(close,length1));
        PlotNumeric("ma1+Close*0.005",Average(close,length1)+Close*0.005);
        PlotNumeric("ma1-Close*0.005",Average(close,length1)-Close*0.005);
        shuju=Average(close,length1);
        shujuH=Average(close,length1)+Close*0.005;
        shujuL=Average(close,length1)-Close*0.005;
        pdH=Close>=Highest(Close[1],15);
        pdL=Close<=Lowest(Close[1],15);
        If(pdH==True)
      {
          closeh=close;
          PlotString("Text","高点",High,Green);
          }
           
        If(pdL==True)
          {
           closel=close;
           PlotString("Text","低点",Low,Red);
          }
        buymax=closeh-price;
        sellmax=price-closel;
        jianduoline=price+(buymax*0.7);
        jiankongline=price-(sellmax*0.7);
        pdjianduo=Close<jianduoline;
        pdjiankong=Close>jiankongline;
        jiancangwei=IntPart(length3*buypos);
        
               
        If(Close[1]>shujuH[1] && open[1]>shuju[1] && MarketPosition<=0)
              {
                    if(MarketPosition<>0)
                        BuyToCover(0,Open);
                Buy(0,Open);
                        
                  }
                  
        If(Close[1]<shujuL[1] && open[1]<shuju[1] && MarketPosition>=0)
                  {
                    if(MarketPosition<>0)
                        Sell(0,Open);
                        SellShort(0,Open);
                        
                  }
        
        If(MarketPosition>0 && CurrentBar>n*length2+length1 && CurrentBar<(n+1)*length2+length1)
                  {
                    if(pdjianduo==True )
                        {
                    Sell(jiancangwei,Open);
                        n=n+1;
                        }
                        
                  }
        If(MarketPosition<0 && CurrentBar>=n*length2+length1 && CurrentBar<=(n+1)*length2+length1)
                  {
                    if(pdjiankong==true)
                        {
                    BuyToCover(jiancangwei,Open);
                        n=n+1;
                        }
                        
                  }
        
     If(MarketPosition==1 && close[1]<shujuH[1]&& BarsSinceLastEntry>K5)
             {
                   Sell(0,Open);
                  
             }
          If(MarketPosition==-1 && close[1]>shujuL[1]&& BarsSinceLastEntry>K5)
             {
                   BuyToCover(0,Open);
                  
             }
        End
               

使用道具 举报

Rank: 1

精华
0
UID
170989
积分
37
帖子
30
主题
6
阅读权限
10
注册时间
1970-1-1
最后登录
2014-6-6
6#
发表于 2013-8-27 17:57:05 |只看该作者
只是这种策略应为回撤太大,还不能实战的。

使用道具 举报

Rank: 1

精华
0
UID
170989
积分
37
帖子
30
主题
6
阅读权限
10
注册时间
1970-1-1
最后登录
2014-6-6
7#
发表于 2013-8-27 17:58:56 |只看该作者
如果你用在几分钟,都有30分钟那种资金线的话就可以实战了

使用道具 举报

Rank: 1

精华
0
UID
170989
积分
37
帖子
30
主题
6
阅读权限
10
注册时间
1970-1-1
最后登录
2014-6-6
8#
发表于 2013-8-27 18:07:50 |只看该作者
放大到80000K线测rb888或if888,用3分钟,如果资金曲线(有30度斜率)还是往上爬行的。还要保证没有未来数据,这样的指标才能试用。

使用道具 举报

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

bottom

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

GMT+8, 2024-5-19 20:11

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部