设为首页收藏本站

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

对手价发单有点问题谁帮改一吓,,之前论坛上找到的 [复制链接]

Rank: 2

精华
0
UID
231668
积分
56
帖子
34
主题
8
阅读权限
30
注册时间
2016-4-6
最后登录
2020-3-5
跳转到指定楼层
1#
发表于 2018-9-2 17:00:38 |只看该作者 |倒序浏览
Params
        Numeric WaitTime(10);        //预设等待时间,单位为秒,可调整
        Numeric ShiftUnit(3);        //下单价格偏移量,可调整
Vars
        Numeric Lots;
        Numeric NewPrice;
        Numeric TimeSeconds;
        Bool    Openning;
Begin
        If ( Q_Last == 0 || ( Date != Date[1] && High == Low ) )         Return;        //如果未开盘,则直接返回
        
        If ( GetGlobalVar(10)==InvalidNumric  )        SetGlobalVar(10,0);        //下单时间初始化
        
        TimeSeconds=Value(Left(TimeToString(CurrentTime),2))*3600                //记录系统当前时间,转化为秒数
                                +Value(Mid(TimeToString(CurrentTime),3,2))*60
                                +Value(Right(TimeToString(CurrentTime),2));
        
        If ( TimeSeconds-GetGlobalVar(10)<WaitTime )        Return;        //如果发单后等待时间小于WaitTime,则返回
        
        Openning = Q_Last > Q_LowLimit && Q_Last < Q_UpperLimit;        //停板情况下不允许建仓

        If ( A_TotalPosition==0 && Openning==true )
        {
                计算开仓手数Lots;
                                 
                If ( 满足开多仓条件 )
                {
                        NewPrice=Q_AskPrice+ShiftUnit*MinMove*PriceScale;        //计算开仓价格
                        A_SendOrder(Enum_Buy,Enum_Entry,Lots,NewPrice);
                        SetGlobalVar(10,TimeSeconds);                        //记录下单时间
                        Return;
                }
                                
                If ( 满足开空仓条件 )
                {
                        NewPrice=Q_BidPrice-ShiftUnit*MinMove*PriceScale;
                        A_SendOrder(Enum_Sell,Enum_Entry,Lots,NewPrice);
                        SetGlobalVar(10,TimeSeconds);
                }
                Return;
        }
               
        If ( A_BuyPosition>0 && 满足平多仓条件 )
        {
                NewPrice=Q_BidPrice-ShiftUnit*MinMove*PriceScale;
                A_SendOrder(Enum_Sell,Enum_Exit,A_BuyPosition,NewPrice);
                SetGlobalVar(10,TimeSeconds);
        }
                                
        If ( A_SellPosition>0 && 满足平空仓条件 )
        {
                NewPrice=Q_AskPrice+ShiftUnit*MinMove*PriceScale;
                A_SendOrder(Enum_Buy,Enum_Exit,A_SellPosition,NewPrice);
                SetGlobalVar(10,TimeSeconds);
        }
End
您需要登录后才可以回帖 登录 | 注册

bottom

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

GMT+8, 2024-4-19 13:22

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部