public ViewModel() { // Init MtApi client _mtApiClient = new MtApi5Client(); _mtApiClient.ConnectionStateChanged += mMtApiClient_ConnectionStateChanged; _mtApiClient.QuoteAdded += mMtApiClient_QuoteAdded; _mtApiClient.QuoteRemoved += mMtApiClient_QuoteRemoved; _mtApiClient.QuoteUpdated += mMtApiClient_QuoteUpdated; _quotesMap = new Dictionary <string, QuoteViewModel>(); ConnectionState = _mtApiClient.ConnectionState; ConnectionMessage = "Disconnected"; Port = 8228; //default local port InitCommands(); var request = new MqlTradeRequest { Action = ENUM_TRADE_REQUEST_ACTIONS.TRADE_ACTION_DEAL , Type = ENUM_ORDER_TYPE.ORDER_TYPE_BUY , Volume = 0.1 , Comment = "Test Trade Request" }; TradeRequest = new MqlTradeRequestViewModel(request); TimeSeriesValues = new TimeSeriesValueViewModel { Count = 100 }; }
public MqlTradeRequestViewModel(MqlTradeRequest reqest) { if (reqest == null) { throw new ArgumentNullException(); } TradeRequest = reqest; }
private ulong SendOrder(string symbol, double price, double volume, ENUM_ORDER_TYPE type) { //make trader request to MT terminal var request = new MqlTradeRequest { Action = ENUM_TRADE_REQUEST_ACTIONS.TRADE_ACTION_DEAL, Symbol = symbol, Type = type, Price = price, Volume = volume, Comment = "Trade Request from Mt5Trade" }; MqlTradeResult result; bool sended = apiClient.OrderSend(request, out result); return((sended == true) ? result.Order : 0); }