понедельник, 22 июля 2019 г.

TradeTerminalQuik Restore PocketOrder

Every Second from Strategy
public void MainBase()
        {         
            RemoveFilledOrders();
            SetPocketOrder();
            Main();
        }

private void RemoveFilledOrders()
        {         
            foreach (IOrder3 o in ClosedOrders)
            {
                ActiveOrderCollection.Remove(o);
            }
            // Remove All with TimeOut
            foreach (var o in ActiveOrderCollection.Items.Where(o=>o.IsRegisteredTimeOutExpired))
            {
                ActiveOrderCollection.Remove(o);
                Evlm2(EvlResult.WARNING, EvlSubject.TECHNOLOGY, StrategyTimeIntTickerString,
                    o.ShortInfo, "Remove(RegisteredTimeOutExpired)", o.ShortDescription,o.ToString());
            }
        }
Z007 Every Second
public override void SetPocketOrder()
        {
            if (PocketOrder == null)
                return;
            if (ActiveOrderCollection.Items.Any())
            {
                Evlm2(EvlResult.WARNING, EvlSubject.TECHNOLOGY, StrategyTimeIntTickerString, "Not Alowed Pocket" + PocketOrder.ShortInfo, PocketOrder.ShortDescription, "Not Alowed Due to Orders Exist", PocketOrder.ToString());
                foreach (var o in ActiveOrderCollection.Items)
                {
                    Evlm2(EvlResult.WARNING, EvlSubject.TECHNOLOGY, StrategyTimeIntTickerString, "Extra" + o.ShortInfo, o.ShortDescription, o.ToString(), "");
                }
                return;
            }

            ActiveOrderCollection.RegisterOrder(PocketOrder);
            TradeTerminal.SetLimitOrder(PocketOrder);

            Evlm2(EvlResult.SUCCESS, EvlSubject.TECHNOLOGY, StrategyTimeIntTickerString, "Set Pocket"+PocketOrder.ShortInfo, PocketOrder.ShortDescription, PocketOrder.ToString(), "");

            PocketOrder = null;
        }

From Z007 EveryBar

RemoveOrdersRegistered();

            KillAllOrders2();

            #region ValidOrdersSoft  
            // ValidSoft Order
            //public bool IsValidSoft => Status == OrderStatusEnum.Activated ||
            //                       Status == OrderStatusEnum.Sended ||
            //                       Status == OrderStatusEnum.Registered ||
            //                       Status == OrderStatusEnum.Confirmed ||
            //                       Status == OrderStatusEnum.PartlyFilled ||
            //                       Status == OrderStatusEnum.PendingToActivate;
            #endregion
            if (ValidOrdersSoft.Any())
            {
                foreach (var ord in ValidOrdersSoft.ToList())
                {
                    Evlm2(EvlResult.WARNING, EvlSubject.TECHNOLOGY,
                        StrategyTimeIntTickerString, "Extra" + ord.ShortInfo, ord.ShortDescription,
                        "SetOrder(Active Or Pending Orders Detected)", ord.ToString());
                }

                 PocketOrder = ActiveOrderCollection
                                .CreateOrder(this, operation, OrderTypeEnum.Limit, 0, _currentLimitPrice, contract, "");

                Evlm2(EvlResult.WARNING, EvlSubject.TECHNOLOGY, StrategyTimeIntTickerString,
                        "Try to Set Pocket" + PocketOrder.ShortInfo , PocketOrder.ShortDescription,
                         PocketOrder.ToString(), "");


                return;


protected void KillAllOrders2()
        {
            RemoveFilledOrders();

            try
            {
                foreach (IOrder3 o in ActiveOrdersSoft)
                {
                    TradeContext.Evlm(EvlResult.INFO, EvlSubject.TECHNOLOGY,
                        StrategyTimeIntTickerString, o.ShortInfo, o.ShortDescription,
                        "Try To KILL ORDER", o.ToString());
                    if (o.IsLimit)
                    {
                        TradeTerminal.KillLimitOrder(o);
                    }
                    else if (o.IsStopLimit)
                        TradeTerminal.KillStopOrder(Ticker.ClassCode, Ticker.Code, o.Number);
                }
            }
            catch (Exception e)
            {
                SendExceptionMessage3(StrategyTickerString, "Strategy.KillAllOrder2()", "", "", e);
                // throw;
            }
        }



понедельник, 15 июля 2019 г.

Strategy 212

case 212:
                            if (operation > 0)
                            {
                                comment = "Buy MA";
                                price = Ticker.ToMinMove(Ma, +1);                           
                                boo = true;
                                }
                            else if (operation < 0)
                            {
                                comment = "Sell Ma";
                                price = Ticker.ToMinMove(Ma, -1);                           
                                boo = true;
                            }
                            break;
                        // Flat + Impulse
                        case 2120:
                            if (operation > 0)
                            {
                                comment = "Buy MA";
                                price = IsFlat
                                    ? Ticker.ToMinMove(Ma, +1)
                                    : Ticker.ToMinMove((Ma + High) / 2.0d, +1);
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell Ma";
                                price = IsFlat
                                    ? Ticker.ToMinMove(Ma, -1)
                                    : Ticker.ToMinMove((Ma + Low) / 2.0d, -1);
                                boo = true;
                            }
                            break;
                        // Flat + Impulse
                        case 2123:
                            if (operation > 0)
                            {
                                comment = "Buy MA";
                                price = IsImpulse
                                    ? Ticker.ToMinMove(Ma, +1)
                                    : Ticker.ToMinMove((Ma + High) / 2.0d, +1);
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell Ma";
                                price = IsFlat
                                    ? Ticker.ToMinMove(Ma, -1)
                                    : Ticker.ToMinMove((Ma + Low) / 2.0d, -1);
                                boo = true;
                            }
                            break;
                        // ATR
                        case 2124:
                            if (operation > 0)
                            {
                                comment = "Buy MA";
                                price = ((Atr2)Atr).IsSlowHigher
                                    ? Ticker.ToMinMove(Ma, +1)
                                    : Ticker.ToMinMove((Ma + High) / 2.0d, +1);
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell Ma";
                                price = ((Atr2)Atr).IsSlowHigher
                                    ? Ticker.ToMinMove(Ma, -1)
                                    : Ticker.ToMinMove((Ma + Low) / 2.0d, -1);
                                boo = true;
                            }
                            break;
                        // ATR
                        case 2125:
                            if (operation > 0)
                            {
                                comment = "Buy MA";
                                price = ((Atr2)Atr).IsFastHigher
                                    ? Ticker.ToMinMove(Ma, +1)
                                    : Ticker.ToMinMove((Ma + High) / 2.0d, +1);
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell Ma";
                                price = ((Atr2)Atr).IsFastHigher
                                    ? Ticker.ToMinMove(Ma, -1)
                                    : Ticker.ToMinMove((Ma + Low) / 2.0d, -1);
                                boo = true;
                            }
                            break;

                        // Impulse
                        case 2121:
                            if (operation > 0)
                            {
                                comment = "Buy (MA+High)/2";
                                price = Ticker.ToMinMove((Ma + High) / 2.0d, +1);
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell (Ma+Low)/2";
                                price = Ticker.ToMinMove((Ma + Low) / 2.0d, -1);
                                boo = true;
                            }
                            break;
                        // Flat
                        case 2122:
                            if (operation > 0)
                            {
                                comment = "Buy MA";
                                price = Ticker.ToMinMove(Ma, +1);
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell Ma";
                                price = Ticker.ToMinMove(Ma, -1);
                                boo = true;
                            }
                            break;
                        case 221:
                            if (operation > 0)
                            {
                                comment = "Buy (MA+Low)/2";
                                price = Ticker.ToMinMove( (Ma + Low)/2.0d, +1);                   
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell (Ma+Hihg)/2";
                                price = Ticker.ToMinMove( (Ma + High)/2.0d, -1);
                                boo = true;
                            }
                            break;
                        case 19:
                            if (operation > 0)
                            {
                                comment = "Buy MA";
                                price = Ticker.ToMinMove(Ma, +1);
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell Ma";
                                price = Ticker.ToMinMove(Ma, -1);
                                boo = true;
                            }
                            break;
                        default:
                            if (operation > 0)
                            {
                                comment = "Buy MA";
                                price = Ticker.ToMinMove(Ma, +1);
                                boo = true;
                            }
                            else if (operation < 0)
                            {
                                comment = "Sell Ma";
                                price = Ticker.ToMinMove(Ma, -1);
                                boo = true;
                            }
                            break;
                    }