Ejemplo n.º 1
0
        /// <summary>
        /// Get signal for the bar
        /// </summary>
        /// <returns></returns>
        protected SignalType GetSignal(int bar)
        {
            SignalType result = SignalType.None;

            TradeRobotics.DataProviders.Quik.Dom.Order fatOrder = GetFatOrder(Date[bar]);
            if (fatOrder == null ||
                fatOrder == lastProcessedFatOrder ||
                (Date[bar] - lastSignalTime).Minutes < 1
                )
            {
                return(SignalType.None);
            }
            else if (fatOrder.OrderType == TradeRobotics.DataProviders.Quik.Dom.OrderType.Ask)
            {
                lastProcessedFatOrder = fatOrder;
                lastSignalTime        = Date[bar];
                return(SignalType.Sell);
            }
            else if (fatOrder.OrderType == TradeRobotics.DataProviders.Quik.Dom.OrderType.Bid)
            {
                lastProcessedFatOrder = fatOrder;
                lastSignalTime        = Date[bar];
                return(SignalType.Buy);
            }
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor from DDE table
 /// </summary>
 /// <param name="table"></param>
 public Level2(string symbol, object[][] table, DateTime time)
     : this()
 {
     Symbol = symbol;
     Time = time;
     // Parse rows to bars
     foreach (object[] row in table)
     {
         try
         {
             Order order = new Order(row);
             Orders.Add(order);
         }
         catch (Exception ex)
         {
             // First row Exception when processing table with header
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get order with largest volume
        /// </summary>
        /// <returns></returns>
        protected TradeRobotics.DataProviders.Quik.Dom.Order GetFatOrder(DateTime time)
        {
            if (Level2History.Count == 0)
            {
                return(null);
            }

            // Get latest level 2
            Level2 level2 = Level2History.LastOrDefault(curLevel2 => curLevel2.Time <= time);

            if (level2 == null)
            {
                return(null);
            }

            TradeRobotics.DataProviders.Quik.Dom.Order firstRequest  = new TradeRobotics.DataProviders.Quik.Dom.Order();
            TradeRobotics.DataProviders.Quik.Dom.Order secondRequest = new TradeRobotics.DataProviders.Quik.Dom.Order();

            foreach (TradeRobotics.DataProviders.Quik.Dom.Order request in level2.Orders)
            {
                if (request.Volume > firstRequest.Volume)
                {
                    secondRequest = firstRequest;
                    firstRequest  = request;
                }
            }
            //double averageVolume = level2.Orders.Average(curLevel2 => curLevel2.Volume);

            // If order is fat, return it
            if (firstRequest.Volume >= secondRequest.Volume * fatOrderCriteria.Value)

            {
                return(firstRequest);
            }
            return(null);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Get signal for the bar
 /// </summary>
 /// <returns></returns>
 protected SignalType GetSignal(int bar)
 {
     SignalType result = SignalType.None;
     TradeRobotics.DataProviders.Quik.Dom.Order fatOrder = GetFatOrder(Date[bar]);
     if (fatOrder == null
         || fatOrder == lastProcessedFatOrder
         || (Date[bar] - lastSignalTime).Minutes <1
         )
     {
         return SignalType.None;
     }
     else if (fatOrder.OrderType == TradeRobotics.DataProviders.Quik.Dom.OrderType.Ask)
     {
         lastProcessedFatOrder = fatOrder;
         lastSignalTime = Date[bar];
         return SignalType.Sell;
     }
     else if (fatOrder.OrderType == TradeRobotics.DataProviders.Quik.Dom.OrderType.Bid)
     {
         lastProcessedFatOrder = fatOrder;
         lastSignalTime = Date[bar];
         return SignalType.Buy;
     }
     return result;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Get order with largest volume
        /// </summary>
        /// <returns></returns>
        protected TradeRobotics.DataProviders.Quik.Dom.Order GetFatOrder(DateTime time)
        {
            if (Level2History.Count == 0)
                return null;

            // Get latest level 2
            Level2 level2 =  Level2History.LastOrDefault(curLevel2 => curLevel2.Time <= time);
            if (level2 == null)
                return null;

            TradeRobotics.DataProviders.Quik.Dom.Order firstRequest = new TradeRobotics.DataProviders.Quik.Dom.Order();
            TradeRobotics.DataProviders.Quik.Dom.Order secondRequest = new TradeRobotics.DataProviders.Quik.Dom.Order();

            foreach(TradeRobotics.DataProviders.Quik.Dom.Order request in level2.Orders)
            {
                if (request.Volume > firstRequest.Volume)
                {
                    secondRequest = firstRequest;
                    firstRequest = request;
                }
            }
            //double averageVolume = level2.Orders.Average(curLevel2 => curLevel2.Volume);

            // If order is fat, return it
            if(firstRequest.Volume >= secondRequest.Volume * fatOrderCriteria.Value)

            {
                return firstRequest;
            }
            return null;
        }