public void Start() { TrenderOrderManager orderManager = new TrenderOrderManager(_mqlApi, _symbol); var volume = orderManager.GetAvailableVolume(_symbol); OpenOrderRequest openOrderRequest = new OpenOrderRequest { OrderType = _trenDirection == TrendDirectionEnum.UP ? OrderTypeEnum.BUY : OrderTypeEnum.SELL, Volume = volume, // Todo: Get from DB! Slippage = 3, StopLoss = 0, TakeProfit = 0, Comment = "Comment", Magic = 1000000, Expiration = DateTime.MinValue }; OpenOrderResponse openOrderResponse = orderManager.OpenOrder(openOrderRequest); }
public OpenOrderResponse OpenOrder(OpenOrderRequest orderRequest) { var symbol = _symbol; var command = orderRequest.OrderType == OrderTypeEnum.BUY ? 0 : 1; var volume = orderRequest.Volume; var price = orderRequest.OrderType == OrderTypeEnum.BUY ? _mqlApi.Ask : _mqlApi.Bid; var slippage = orderRequest.Slippage; var stopLoss = orderRequest.StopLoss; var takeProfit = orderRequest.TakeProfit; var comment = orderRequest.Comment; var magic = orderRequest.Magic; var expiration = orderRequest.Expiration; try { _mqlApi.RefreshRates(); var result = _mqlApi.OrderSend(symbol, command, volume, price, slippage, stopLoss, takeProfit, comment, magic, expiration); return new OpenOrderResponse { }; } catch (Exception exception) { // Log exception throw; } }