- 精华
- 0
- 在线时间
- 168 小时
- UID
- 212983
- 积分
- 49
- 帖子
- 34
- 阅读权限
- 10
- 注册时间
- 2015-7-6
- 最后登录
- 2023-4-19
- 精华
- 0
- UID
- 212983
- 积分
- 49
- 帖子
- 34
- 主题
- 15
- 阅读权限
- 10
- 注册时间
- 2015-7-6
- 最后登录
- 2023-4-19
|
本帖最后由 lolo1973 于 2018-11-22 10:29 编辑
- Params
- Numeric longPrice(3650);
- Numeric shortPrice(3000);
- Numeric shiftUnits(100); //下单价格偏移跳数
- Numeric waitTime(50); //撤单前等待时长,秒
-
- Vars
- Numeric timeSeconds;
- Numeric buyPosition;
- Numeric sellPosition;
- Numeric minPoint;
- Numeric units;
- String mySection;
- String orderStatus;
- String orderTime;
- Bool buyPositionCon;
- Bool sellPositionCon;
- String curTime; //currentTime
- String path;
-
- Begin
- If(!CallAuctionFilter) Return;
- path = "C:\\Users\\Administrator\\Desktop\\00_" + FormulaName + "_" + Symbol + ".log";
- mySection = FormulaName + Symbol;
- orderStatus = "order_status";
- orderTime = "order_time";
- curTime = TimeToString(CurrentTime);
-
- minPoint = MinMove * PriceScale;
- units = 1;
- If(BarStatus == 0)
- {
- SetTBProfileString(mySection, orderStatus, Text(0));
- SetTBProfileString(mySection, orderTime, Text(0));
- }
-
- timeSeconds = Value(Left(curTime, 2)) * 3600 + Value(Mid(curTime, 3, 2)) * 60 + Value(Right(curTime, 2));
-
- FileAppend(path, "----------------------------" + curTime + "--------------------------");
- FileAppend(path, "initial order status: " + GetTBProfileString(mySection, orderStatus) + "; value of order status is: "
- + text(Value(GetTBProfileString(mySection, orderStatus))));
- FileAppend(path, "order status == 0: " + IIFString(Value(GetTBProfileString(mySection, orderStatus)) == 0, "true" ,"false"));
-
- //开仓
- If(Value(GetTBProfileString(mySection, orderStatus)) == 0);
- {
- If(Q_AskPrice >= longPrice)
- {
- A_SendOrder(Enum_Buy, Enum_Entry, units, Q_AskPrice - shiftUnits * minPoint);
- SetTBProfileString(mySection, orderStatus, Text(1));
- SetTBProfileString(mySection, orderTime, Text(timeSeconds));
- FileAppend(path, "long condition filled----order status is: " + GetTBProfileString(mySection, orderStatus) +
- "-----order time is: " + curTime);
- }Else If(Q_BidPrice <= shortPrice)
- {
- A_SendOrder(enum_sell, enum_entry, units, Q_BidPrice + shiftUnits * minPoint);
- SetTBProfileString(mySection, orderStatus, Text(-1));
- SetTBProfileString(mySection, orderTime, Text(timeSeconds));
- }
- }
- buyPosition = A_BuyPosition;
- sellPosition = A_SellPosition;
- buyPositionCon = (buyPosition > 0);
- sellPositionCon = (sellPosition < 0);
- FileAppend(path, "buyPosition = " + Text(buyPosition));
- If(Value(GetTBProfileString(mySection, orderStatus)) == 1)
- {
- If(timeSeconds - Value(GetTBProfileString(mySection, orderTime)) >= waitTime and !buyPositionCon)
- {
- A_DeleteOrder();
- SetTBProfileString(mySection, orderStatus, Text(0));
- }
- }else If(Value(GetTBProfileString(mySection, orderStatus)) == -1)
- {
- If(timeSeconds - Value(GetTBProfileString(mySection, orderTime)) >= waitTime and !sellPositionCon)
- {
- A_DeleteOrder();
- SetTBProfileString(mySection, orderStatus, Text(0));
- }
- }
- End
复制代码 通过fileappend,开仓之前order status的值确定为1,但程序还是能进入到开仓的条件中,不明所以。 |
|