设为首页收藏本站

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

求助问题所在 [复制链接]

Rank: 1

精华
0
UID
289823
积分
3
帖子
2
主题
1
阅读权限
10
注册时间
2020-3-17
最后登录
2021-5-18
跳转到指定楼层
1#
发表于 2021-5-6 11:32:38 |只看该作者 |倒序浏览
Params
        //此处添加参数
String sym("rb2110.SHFE");  // 交易品种
Numeric gridstartprice(5600);// 网格起始价格
Integer gridstep(10);  // 网格大小
Integer gridlength(10);   // 网格格数
Integer bs(1);   // 交易方向 ,1 多,-1 空
Vars
        //此处添加变量
        Numeric avg;
        Global Integer timerId;
        Series <Numeric> i;
        Series <Numeric> flag;
        Series <Numeric> curgridprice;
        Series <Numeric> tpprice;
        Series <Numeric> reprice;
               
Array<Integer> orderIds;
       

Events
        //此处实现事件函数
       

        //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组
        OnBar(ArrayRef<Integer> indexs)
        {
               
                If(AccountDataExist() And IsTradingTime(SystemDateTime) And flag==0  And A_BuyPosition<11)
                {
                        Commentary("flag="+Text(flag));
                        For i = 1 To gridlength
                        {
                                curgridprice = gridstartprice-(i-1)*gridstep;
                                If(A_SendOrderEx(Enum_Buy,Enum_Entry,1,curgridprice,orderIDs))
                                {
                                                        flag=1;
                                //FileAppend
                                }
                        }                               
                }
        }

       
        //成交更新事件函数,参数ordFill表示更新的成交结构体
        OnFill(FillRef ordFill)
        {
                // 如果开仓挂单成交了,则挂止盈单
                If(ordFill.combOffset==Enum_Entry)
                {
            tpprice= ordfill.price + gridstep;
                        A_SendOrderEx(ordFill.symbol,Enum_Sell,Enum_Exit,1,tpprice,orderIds);
                       
                }
                Else
                {
                        reprice=ordfill.price - gridstep;   // 止盈单成交,继续按照原价挂单
                        A_SendOrderEx(ordFill.symbol,Enum_Buy,Enum_Entry,1,reprice,orderIDs);  
                }
        }

       

Rank: 1

精华
0
UID
289823
积分
3
帖子
2
主题
1
阅读权限
10
注册时间
2020-3-17
最后登录
2021-5-18
2#
发表于 2021-5-6 11:34:00 |只看该作者
目前每次发单都是一样的价格,网格价格不对,不知道是啥原因,谢谢!

使用道具 举报

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

bottom

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

GMT+8, 2024-5-2 17:56

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部