设为首页收藏本站

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

请问管理员为什么会出现同一价位连续开平仓呢? [复制链接]

Rank: 1

精华
0
UID
286292
积分
40
帖子
16
主题
8
阅读权限
10
注册时间
2019-11-30
最后登录
2019-12-26
跳转到指定楼层
1#
发表于 2019-12-18 13:58:10 |只看该作者 |倒序浏览
请问管理员,我策略这样写,为什么在同一根K线上会出现同一价位连续开平仓呢?




//------------------------------------------------------------------------
// 简称: dtjy
// 名称: 多头交易
// 类别: 公式应用
// 类型: 用户应用
//------------------------------------------------------------------------

Params
   
        Numeric ATRLength(26);
    Numeric ss(1);
        

Vars
    Numeric MinPoint;           
    Numeric MyEntryPrice;      
    NumericSeries ATR;                  
    Numeric N;                 
    Numeric zydw;
    Numeric zsdw;
        
        
        
        
Begin
   
        If(!CallAuctionFilter()) Return;

        ATR = XAverage(TrueRange,ATRLength);
        N = ATR[1];
    MinPoint = MinMove * PriceScale;
    MyEntryPrice = AvgEntryPrice;  
    zydw = IntPart(MyEntryPrice + (N * MinPoint)*2);
    zsdw = IntPart(MyEntryPrice - (N * MinPoint)*1);
        
  
        
         
        
        //-----------------------------------开仓-------------------------------------
        If(BarStatus==2 && Time==0.210000 && CurrentTime <= 0.210000 && MarketPosition==0) return;
        
        
        {
          FileAppend("d:\\marketpostion.log"," currentbar: "+text(currentbar)+ "||  执行buy命令前的marketposition值: " +Text(marketposition));
        
          Buy(ss,open);
         
        
          FileAppend("d:\\marketpostion.log"," currentbar: "+text(currentbar)+ "||  执行buy命令后的marketposition值: " +Text(marketposition));
        }
         
         
        
         
        //--------------------------------------止盈------------------------------------
         
         
         
        
        
        if (MarketPosition==1&&High>=zydw)
        
        
   
        {   
         If(open > zydw) zydw = open;      // 如果该Bar开盘价有跳空触发,则用开盘价代替
               
                 Sell(0,zydw);
                 
                 buy(ss,zydw);
                 
        
    }
        
        //----------------------------止损--------------------------------------
        
        
        if (MarketPosition==1&&low<=zsdw)// 止损条件表达式
        
        {
                If(open < zsdw) zsdw = open;      // 如果该Bar开盘价有跳空触发,则用开盘价代替
               
                Sell(0,zsdw);
                 
                SellShort(ss,zsdw);
        }
     
        //-------------------------------------收盘平仓----------------------------------------

  
    If((Date[-1]!=InvalidInteger && Date!=Date[-1])||(Date[-1]==InvalidInteger && Date < CurrentDate))
    {
        Sell(0,Close);
        BuyToCover(0,Close);
    }Else If(Date==CurrentDate && Time==0.1455 && CurrentTime>=0.1459)
    {
        Sell(0,Close);
        BuyToCover(0,Close);
    }

End
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
您需要登录后才可以回帖 登录 | 注册

bottom

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

GMT+8, 2024-5-18 20:45

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部