/// <summary>Called when new data is received</summary>
        public override void Step()
        {
            base.Step();
            if (!Instrument.NewCandle)
            {
                return;
            }

            var mcs = Instrument.MCS;

            // If there is an existing position, wait for it to close
            if (Positions.Count() >= MaxPositions)
            {
                return;
            }

            // If there is no price channel
            if (Channel == null)
            {
                return;
            }

            // Cancel any pending orders and replace them with new ones based on this channel
            Broker.CancelAllPendingOrders(Label);

            Dump();

            // The Channel
            var chan = Channel.Value;
            var risk = Risk / MaxPositions;
            var sign = chan.PrecedingTrendSign;

            //		// Create a pending order on the side opposite the preceding trend
            //		var ep = sign > 0 ? chan.Price.End + 0.5*mcs : chan.Price.Beg - 0.5*mcs;
            //		var sl = (QuoteCurrency?)null;//sign > 0 ? chan.Price.Beg : chan.Price.End;
            //		var tp = (QuoteCurrency?)null;//ep + sign * Math.Abs(ep - sl);
            //		var sl_rel = 5*mcs;//Math.Abs(ep - sl);
            //		var vol = Broker.ChooseVolume(Instrument, sl_rel, risk:risk);
            //		var trade = new Trade(Instrument, CAlgo.SignToTradeType(chan.PrecedingTrendSign), Label, ep, sl, tp, vol);
            //		trade.Expiration = Instrument.ExpirationTime(5);
            //		Broker.CreatePendingOrder(trade);

            // Create pending orders on either side of the channel
            {
                var ep    = chan.Price.End + 0.5 * mcs;
                var sl    = chan.Price.Beg;
                var tp    = (QuoteCurrency?)null;             // ep + chan.Price.Size * 5;
                var vol   = Broker.ChooseVolume(Instrument, Math.Abs(ep - sl), risk: risk);
                var trade = new Trade(Instrument, TradeType.Buy, Label, ep, sl, tp, vol);
                trade.Expiration = Instrument.ExpirationTime(5);
                Broker.CreatePendingOrder(trade);
            }
            {
                var ep    = chan.Price.Beg - 0.5 * mcs;
                var sl    = chan.Price.End;
                var tp    = (QuoteCurrency?)null;             // ep - chan.Price.Size * 5;
                var vol   = Broker.ChooseVolume(Instrument, Math.Abs(ep - sl), risk: risk);
                var trade = new Trade(Instrument, TradeType.Sell, Label, ep, sl, tp, vol);
                trade.Expiration = Instrument.ExpirationTime(5);
                Broker.CreatePendingOrder(trade);
            }

            // Debugging
            {
                var c = chan;
                for (; Channels.Count != 0 && c.Idx.Contains(Channels.Back().Idx);)
                {
                    Channels.PopBack();
                }
                Channels.Add(c);
            }
        }