示例#1
0
 private TradingOrderCommand(TradingOrderType trade_order_type, double volume, double price, double slippage, double stop_loss, double take_profit, bool use_limits)
 {
     this.OrderType  = trade_order_type;
     this.Volume     = volume;
     this.Price      = price;
     this.Slippage   = slippage;
     this.StopLoss   = stop_loss;
     this.TakeProfit = take_profit;
     this.UseLimits  = use_limits;
 }
示例#2
0
        public static AResponse ReadStatic(BinaryReader reader)
        {
            TradingOrderType order_type  = reader.ReadEnum <TradingOrderType>();
            double           volume      = reader.ReadDouble();
            double           price       = reader.ReadDouble();
            double           slippage    = reader.ReadDouble();
            double           stop_loss   = reader.ReadDouble();
            double           take_profit = reader.ReadDouble();

            return(new ResponseAccountOnTick(new TradingOrderCommand(order_type, volume, price, slippage, stop_loss, take_profit)));
        }
示例#3
0
        // Close contructor
        public TradingOrder(TradingOrderType order_type, int order_ticket, DateTimeUTC open_date_time, double open_price, double volume, double commission_for_order,
                            bool use_limits, double stop_loss, double take_profit,
                            DateTimeUTC close_date_time, double close_price)
        {
            this.OrderType          = order_type;
            this.OrderTicket        = order_ticket;
            this.OpenDateTime       = open_date_time;
            this.OpenPrice          = open_price;
            this.Volume             = volume;
            this.CommissionForOrder = commission_for_order;


            this.UseLimits  = use_limits;
            this.StopLoss   = stop_loss;
            this.TakeProfit = take_profit;


            this.CloseDateTime = close_date_time;
            this.ClosePrice    = close_price;

            this.IsOpen = false;

            switch (order_type)
            {
            case TradingOrderType.Long:
                this.Profit = ((ClosePrice - OpenPrice) * Volume) - commission_for_order;
                break;

            case TradingOrderType.Short:
                this.Profit = ((OpenPrice - ClosePrice) * Volume) - commission_for_order;
                break;

            default:
                throw new Exception("Unknown order type");
            }
        }
示例#4
0
 //Simple open contructor
 public TradingOrder(TradingOrderType order_type, int order_ticket, DateTimeUTC open_date_time, double open_price, double volume, double commission_for_order)
     : this(order_type, order_ticket, open_date_time, open_price, volume, commission_for_order, false, 0, 0, new DateTimeUTC(), 0)
 {
     this.IsOpen = true;
 }
示例#5
0
 //limit open contructor
 public TradingOrder(TradingOrderType order_type, int order_ticket, DateTimeUTC open_date_time, double open_price, double volume, double commission_for_order,
                     bool use_limits, double stop_loss, double take_profit)
     : this(order_type, order_ticket, open_date_time, open_price, volume, commission_for_order, use_limits, stop_loss, take_profit, new DateTimeUTC(), 0)
 {
     this.IsOpen = true;
 }
示例#6
0
 public TradingOrderCommand(TradingOrderType trade_order_type, double volume, double price, double slippage)
     : this(trade_order_type, volume, price, slippage, 0, 0, false)
 {
 }
示例#7
0
 public TradingOrderCommand(TradingOrderType trade_order_type, double volume, double price, double slippage, double stop_loss, double take_profit)
     : this(trade_order_type, volume, price, slippage, stop_loss, take_profit, true)
 {
 }