设为首页收藏本站

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

A函数+全局变量控制,还是重复发单问题 [复制链接]

Rank: 1

精华
0
UID
212983
积分
49
帖子
34
主题
15
阅读权限
10
注册时间
2015-7-6
最后登录
2023-4-19
跳转到指定楼层
1#
发表于 2018-11-22 10:28:01 |只看该作者 |倒序浏览
本帖最后由 lolo1973 于 2018-11-22 10:29 编辑
  1. Params
  2.         Numeric longPrice(3650);
  3.         Numeric shortPrice(3000);
  4.         Numeric shiftUnits(100);   //下单价格偏移跳数
  5.         Numeric waitTime(50);    //撤单前等待时长,秒
  6.        
  7. Vars
  8.         Numeric timeSeconds;
  9.         Numeric buyPosition;
  10.         Numeric sellPosition;
  11.         Numeric minPoint;
  12.         Numeric units;
  13.         String mySection;
  14.         String orderStatus;
  15.         String orderTime;
  16.         Bool buyPositionCon;
  17.         Bool sellPositionCon;
  18.         String curTime;     //currentTime
  19.         String path;
  20.        
  21. Begin
  22.         If(!CallAuctionFilter) Return;
  23.         path = "C:\\Users\\Administrator\\Desktop\\00_" + FormulaName + "_" + Symbol + ".log";
  24.         mySection = FormulaName + Symbol;
  25.         orderStatus = "order_status";
  26.         orderTime = "order_time";
  27.         curTime = TimeToString(CurrentTime);
  28.        
  29.         minPoint = MinMove * PriceScale;
  30.         units = 1;
  31.         If(BarStatus == 0)
  32.         {
  33.                 SetTBProfileString(mySection, orderStatus, Text(0));
  34.                 SetTBProfileString(mySection, orderTime, Text(0));
  35.         }
  36.                
  37.         timeSeconds = Value(Left(curTime, 2)) * 3600 + Value(Mid(curTime, 3, 2)) * 60 + Value(Right(curTime, 2));
  38.        
  39.         FileAppend(path, "----------------------------" + curTime + "--------------------------");
  40.         FileAppend(path, "initial order status: " + GetTBProfileString(mySection, orderStatus) + ";  value of order status is: "
  41.                                         + text(Value(GetTBProfileString(mySection, orderStatus))));
  42.         FileAppend(path, "order status == 0: " + IIFString(Value(GetTBProfileString(mySection, orderStatus)) == 0, "true" ,"false"));
  43.        
  44.         //开仓
  45.         If(Value(GetTBProfileString(mySection, orderStatus)) == 0);
  46.         {
  47.                 If(Q_AskPrice >= longPrice)
  48.                 {
  49.                         A_SendOrder(Enum_Buy, Enum_Entry, units, Q_AskPrice - shiftUnits * minPoint);
  50.                         SetTBProfileString(mySection, orderStatus, Text(1));
  51.                         SetTBProfileString(mySection, orderTime, Text(timeSeconds));
  52.                         FileAppend(path, "long condition filled----order status is: " + GetTBProfileString(mySection, orderStatus) +
  53.                                                 "-----order time is: " + curTime);
  54.                 }Else If(Q_BidPrice <= shortPrice)
  55.                 {
  56.                         A_SendOrder(enum_sell, enum_entry, units, Q_BidPrice + shiftUnits * minPoint);
  57.                         SetTBProfileString(mySection, orderStatus, Text(-1));
  58.                         SetTBProfileString(mySection, orderTime, Text(timeSeconds));
  59.                 }
  60.         }
  61.         buyPosition = A_BuyPosition;
  62.         sellPosition = A_SellPosition;
  63.         buyPositionCon = (buyPosition > 0);
  64.         sellPositionCon = (sellPosition < 0);
  65.         FileAppend(path, "buyPosition = " + Text(buyPosition));
  66.         If(Value(GetTBProfileString(mySection, orderStatus)) == 1)
  67.         {
  68.                 If(timeSeconds - Value(GetTBProfileString(mySection, orderTime)) >= waitTime and !buyPositionCon)
  69.                 {
  70.                         A_DeleteOrder();
  71.                         SetTBProfileString(mySection, orderStatus, Text(0));
  72.                 }
  73.         }else If(Value(GetTBProfileString(mySection, orderStatus)) == -1)
  74.         {
  75.                 If(timeSeconds - Value(GetTBProfileString(mySection, orderTime)) >= waitTime and !sellPositionCon)
  76.                 {
  77.                         A_DeleteOrder();
  78.                         SetTBProfileString(mySection, orderStatus, Text(0));
  79.                 }
  80.         }
  81. End
复制代码
通过fileappend,开仓之前order status的值确定为1,但程序还是能进入到开仓的条件中,不明所以。

Rank: 1

精华
0
UID
212983
积分
49
帖子
34
主题
15
阅读权限
10
注册时间
2015-7-6
最后登录
2023-4-19
2#
发表于 2018-11-22 10:35:39 |只看该作者
本帖最后由 lolo1973 于 2018-11-22 10:37 编辑


使用道具 举报

Rank: 10Rank: 10Rank: 10

精华
3
UID
5
积分
26584
帖子
12686
主题
49
阅读权限
200
注册时间
2007-7-20
最后登录
2021-11-3
3#
发表于 2018-11-22 10:53:56 |只看该作者
第45行的if条件后有加了分号啊。。这样自然限制不住的。

使用道具 举报

Rank: 1

精华
0
UID
212983
积分
49
帖子
34
主题
15
阅读权限
10
注册时间
2015-7-6
最后登录
2023-4-19
4#
发表于 2018-11-22 11:36:57 |只看该作者
小米 发表于 2018-11-22 10:53
第45行的if条件后有加了分号啊。。这样自然限制不住的。

露出了不争气的微笑。。多谢!

使用道具 举报

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

bottom

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

GMT+8, 2024-4-24 19:16

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部