private static TradingOrder CloseOrder(TradingOrder trade_order, DateTimeUTC current_date_time, double current_bid, double current_ask) { switch (trade_order.OrderType) { case TradingOrderType.Long: return(trade_order.Close(current_date_time, current_bid)); case TradingOrderType.Short: return(trade_order.Close(current_date_time, current_ask)); default: throw new NotImplementedException(); } }
public void CloseOrder(int order_ticket) { TradingOrder trade_order = OpenOrders[order_ticket]; switch (trade_order.OrderType) { case TradingOrderType.Long: trade_order = trade_order.Close(CurrentDateTime, CurrentBid); break; case TradingOrderType.Short: trade_order = trade_order.Close(CurrentDateTime, CurrentAsk); break; default: throw new Exception("Unknown order type"); } this.ClosedOrders.Add(trade_order); this.OpenOrders.Remove(order_ticket); this.Cash += trade_order.Profit; }