设为首页收藏本站

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

小米,满足条件只减仓1手,实现不了,请帮忙 [复制链接]

Rank: 3Rank: 3

精华
0
UID
222769
积分
175
帖子
104
主题
41
阅读权限
40
注册时间
2015-11-7
最后登录
2021-2-26
跳转到指定楼层
1#
发表于 2016-5-27 08:57:47 |只看该作者 |倒序浏览
满足条件1只减仓1手,条件2减仓1手,如何控制,谢谢
我这给减仓完了
Params
        Numeric Length1(41);                                                                //长周期区间参数
        Numeric Length2(3);                                                                //短周期区间参数
        Numeric IPS(1.2);                                                                                //保护止损波动率参数
        Numeric AtrVal(20);                                //波动率参数
        Numeric jx(107);
        Numeric lots(5);
          Numeric SubSet(8);         // 减仓设置
         Numeric lots1(1);
       
Vars
        NumericSeries ProtectStopL;
        NumericSeries ATR;
        NumericSeries Upperband;
        NumericSeries Lowerband;
        NumericSeries Exitlong;
        NumericSeries Exitshort;
        NumericSeries ma;
        Numeric L2;
        Numeric L1;
        Numeric Minpoint;
        NumericSeries firstPrice;   // 第一次开仓价格
    NumericSeries LastPrice;    // 最后一次开仓价格
    Numeric AddSet(30);         // 加仓设置
   
        Numeric flag(0) ;
       
Begin

        // 集合竞价和小节休息过滤
        If(!CallAuctionFilter()) Return;
       
        Minpoint = Minmove*PriceScale;
    ATR = AvgTrueRange(AtrVal);                                                     //定义ATR
        L1 = Max(Length1,Length2);                                                     //出场周期选择较大的区间参数
        L2 = Min(Length1,Length2);                                                     //出场周期选择较小的区间参数
        Upperband = Highest(High, L1);                                             //长周期最高价区间
        Lowerband = lowest(Low,L1);                                                       //长周期最低价区间
        Exitlong = Lowest(Low,L2);                                                     //短周期最低价区间
        Exitshort = Highest(high,L2);                                             //短周期最高价区间
        ma=Average(c,jx);
        //系统入场
        If(Marketposition == 0 and High >= Upperband[1] + Minpoint And Vol > 0  and c[1]>ma[1])             //价格大于长周期最高价区间入场做多
        {
                Buy(lots, Max(Open, Upperband[1] + 2*Minpoint));firstPrice=LastEntryPrice;
                ProtectStopL = Entryprice - IPS*ATR[1];
        }
       
        //系统出场
        If(MarketPosition == 1 and BarsSinceEntry >0 And Vol > 0)
        {
                If( Low <= ProtectStopL[1] and ProtectStopL[1] >= Exitlong[1])  //价格低于入场价以下一定ATR幅度止损
                {
                        Sell (0,Min(Open-Minpoint,ProtectStopL[1]-Minpoint));
                }
                Else if (Low <= Exitlong[1] - Minpoint)                    //价格低于短周期最低价区间出场
                {
                        Sell(0, Min( Open-Minpoint, Exitlong[1] - 2*Minpoint));
                }
        }
if( MarketPosition == 1 and  h>= firstPrice + SubSet*MinPoint ) {flag=0;}// 减仓
        if (flag==0)
           // firstPrice = firstPrice + SubSet*MinPoint;
            //if(Open >firstPrice) firstPrice = Open;
           { sell(lots1,firstPrice+SubSet*MinPoint-2*Minpoint);flag=flag+1;Commentary("flag1="+text(flag)); }
        
End

Rank: 10Rank: 10Rank: 10

精华
3
UID
5
积分
26584
帖子
12686
主题
49
阅读权限
200
注册时间
2007-7-20
最后登录
2021-11-3
2#
发表于 2016-5-27 10:12:46 |只看该作者
平仓手数不要写为0啊。。改为你想要的1手

使用道具 举报

Rank: 3Rank: 3

精华
0
UID
222769
积分
175
帖子
104
主题
41
阅读权限
40
注册时间
2015-11-7
最后登录
2021-2-26
3#
发表于 2016-5-27 10:33:33 |只看该作者
我的想法是开仓5手,盈利8跳后减仓1手,下面的不对,是比如盈利8跳减仓1手,不停的减仓减完了,而且还偷价了,全部平在最高价了

if( MarketPosition == 1 and  h>= firstPrice + SubSet*MinPoint ) {flag=0;}// 减仓
        if (flag==0)
            // firstPrice = firstPrice + SubSet*MinPoint;
             //if(Open >firstPrice) firstPrice = Open;
            { sell(lots1,firstPrice+SubSet*MinPoint-2*Minpoint);flag=flag+1;Commentary("flag1="+text(flag)); }
附件: 你需要登录才可以下载或查看附件。没有帐号?注册

使用道具 举报

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

bottom

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

GMT+8, 2024-5-9 03:07

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部