Exemplo n.º 1
0
        public override void onTick(Tick tick)
        {
            if (lastOrderID <= 0)
            {
                lastOrderID = OrderOperation.AddOrder(new MarketOrder(OrderSide.Buy, param.BasicVolume, tick.Ask - param.SL, tick.Ask + param.TP));
                return;
            }
            if (!History.Contains(lastOrderID))
            {
                return;
            }

            MarketOrder mOrder = History.GetMarketOrderByID(lastOrderID);

            if (mOrder.Profit > 0)
            {
                lastOrderID = OrderOperation.AddOrder(LimitOrder.SmartConstructor(tick.Ask, tick.Bid, Order.RevertSide(mOrder.Side), param.BasicVolume, 10, param.SL, param.TP));
            }
            else
            {
                lastOrderID = OrderOperation.AddOrder(LimitOrder.SmartConstructor(tick.Ask, tick.Bid, mOrder.Side, ((int)(((double)mOrder.Volume * param.VolCoef))), 10, param.SL, param.TP));
            }
            logger.AddMessage(string.Format("Equity = {0}", Account.GetEquity()));
        }