Beispiel #1
0
        protected int OrderSendInternal(string symbol, OrderType type, OrderSide side, int volume, int openPrice, int sl, int tp, string comment)
        {
            int retResult = 0;

            do
            {
                while (IsTradeContextBusy())
                {
                    Print("TradeContextBusy");
                    Thread.Sleep(100);
                }
                this.Print(string.Format("OrderSend symbol={0};type={1};volume={2};openPrice={3};slippage={4};sl={5};tp={6};comment={7}",
                                         symbol, MetaTypeConvertor.ToMetaOperationType(side, type), (double)volume / 100, Convertor.TranslateFromPipPrice(symbol, openPrice), 15,
                                         Convertor.TranslateFromPipPrice(symbol, sl), Convertor.TranslateFromPipPrice(symbol, tp), comment));

                AsyncCommand aCmd = new AsyncCommand(Commands.OrderSend,
                                                     new object[] { symbol, MetaTypeConvertor.ToMetaOperationType(side, type), (double)volume / 100, Convertor.TranslateFromPipPrice(symbol, openPrice), 15,
                                                                    Convertor.TranslateFromPipPrice(symbol, sl), Convertor.TranslateFromPipPrice(symbol, tp), comment, this.MagicNumber, 0, 0 });
                retResult = (int)ExecuteCommand(aCmd);
                if (retResult > 0)
                {
                    return(retResult);
                }
            } while (GetLastError() == MetaLastErrors.ERR_SERVER_BUSY);
            return(retResult);
        }
Beispiel #2
0
        public double AccountFreeMarginCheck(string symbol, OrderType type, OrderSide side, int volume)
        {
            AsyncCommand cmd = new AsyncCommand(Commands.AccountFreeMarginCheck, new object[] { symbol, MetaTypeConvertor.ToMetaOperationType(side, type), ((double)volume) / 100 });

            ExecuteCommand(cmd);
            return((double)cmd.Result);
        }