From caac11cdada06ddf7397c2bd560f24b9b7b372b8 Mon Sep 17 00:00:00 2001 From: Viacheslav Demydiuk Date: Sun, 14 Jan 2024 21:57:07 +0200 Subject: [PATCH] MtApi5: Moving some functions to new core --- MtApi5/Events/Mt5EventTypes.cs | 11 - MtApi5/ExecutionException.cs | 10 +- MtApi5/Mt5CommandType.cs | 261 ------------------ MtApi5/MtApi5Client.cs | 80 +++--- MtApi5/MtProtocol/FuncResult.cs | 8 + MtApi5/MtProtocol/MqlTick.cs | 12 + MtApi5/MtProtocol/Mt5CommandType.cs | 260 +++++++++++++++++ MtApi5/MtProtocol/Mt5EventTypes.cs | 11 + .../OnTickEvent.cs => MtProtocol/MtQuote.cs} | 6 +- MtApi5/{Events => MtProtocol}/OnBookEvent.cs | 2 +- .../OnLastTimeBarEvent.cs | 4 +- .../OnLockTicksEvent.cs | 2 +- .../OnTradeTransactionEvent.cs | 2 +- MtApi5/{Requests => MtProtocol}/Response.cs | 2 +- 14 files changed, 344 insertions(+), 327 deletions(-) delete mode 100644 MtApi5/Events/Mt5EventTypes.cs delete mode 100755 MtApi5/Mt5CommandType.cs create mode 100755 MtApi5/MtProtocol/FuncResult.cs create mode 100755 MtApi5/MtProtocol/MqlTick.cs create mode 100755 MtApi5/MtProtocol/Mt5CommandType.cs create mode 100755 MtApi5/MtProtocol/Mt5EventTypes.cs rename MtApi5/{Events/OnTickEvent.cs => MtProtocol/MtQuote.cs} (50%) mode change 100644 => 100755 rename MtApi5/{Events => MtProtocol}/OnBookEvent.cs (70%) mode change 100644 => 100755 rename MtApi5/{Events => MtProtocol}/OnLastTimeBarEvent.cs (66%) mode change 100644 => 100755 rename MtApi5/{Events => MtProtocol}/OnLockTicksEvent.cs (72%) mode change 100644 => 100755 rename MtApi5/{Events => MtProtocol}/OnTradeTransactionEvent.cs (84%) mode change 100644 => 100755 rename MtApi5/{Requests => MtProtocol}/Response.cs (81%) mode change 100644 => 100755 diff --git a/MtApi5/Events/Mt5EventTypes.cs b/MtApi5/Events/Mt5EventTypes.cs deleted file mode 100644 index 2d9177ba..00000000 --- a/MtApi5/Events/Mt5EventTypes.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MtApi5.Events -{ - internal enum Mt5EventTypes - { - OnTradeTransaction = 1, - OnBookEvent = 2, - OnTick = 3, - OnLastTimeBar = 4, - OnLockTicks = 5 - } -} diff --git a/MtApi5/ExecutionException.cs b/MtApi5/ExecutionException.cs index 24706d16..9e2ad9a0 100755 --- a/MtApi5/ExecutionException.cs +++ b/MtApi5/ExecutionException.cs @@ -1,13 +1,7 @@ namespace MtApi5 { - public class ExecutionException: Exception + public class ExecutionException(ErrorCode errorCode, string? message) : Exception(message) { - public ExecutionException(ErrorCode errorCode, string? message) - :base(message) - { - ErrorCode = errorCode; - } - - public ErrorCode ErrorCode { get; private set; } + public ErrorCode ErrorCode { get; private set; } = errorCode; } } \ No newline at end of file diff --git a/MtApi5/Mt5CommandType.cs b/MtApi5/Mt5CommandType.cs deleted file mode 100755 index 62e1e92d..00000000 --- a/MtApi5/Mt5CommandType.cs +++ /dev/null @@ -1,261 +0,0 @@ -// ReSharper disable InconsistentNaming -namespace MtApi5 -{ - internal enum Mt5CommandType - { - //NoCommand = 0 - - //trade operations - //OrderSend = 1, - GetQuote = 1, - OrderCalcMargin = 2, - OrderCalcProfit = 3, - //OrderSendAsync = 5, - PositionsTotal = 6, - PositionGetSymbol = 7, - PositionSelect = 8, - PositionGetDouble = 9, - PositionGetInteger = 10, - PositionGetString = 11, - PositionGetTicket = 4, - OrdersTotal = 12, - OrderGetTicket = 13, - OrderSelect = 14, - OrderGetDouble = 15, - OrderGetInteger = 16, - OrderGetString = 17, - HistorySelect = 18, - HistorySelectByPosition = 19, - HistoryOrderSelect = 20, - HistoryOrdersTotal = 21, - HistoryOrderGetTicket = 22, - HistoryOrderGetDouble = 23, - HistoryOrderGetInteger = 24, - HistoryOrderGetString = 25, - HistoryDealSelect = 26, - HistoryDealsTotal = 27, - HistoryDealGetTicket = 28, - HistoryDealGetDouble = 29, - HistoryDealGetInteger = 30, - HistoryDealGetString = 31, - - //Account Information - AccountInfoDouble = 32, - AccountInfoInteger = 33, - AccountInfoString = 34, - - //Access to Timeseries and Indicator Data - SeriesInfoInteger = 35, - Bars = 36, - Bars2 = 1036, - BarsCalculated = 37, -// IndicatorCreate = 38, -// IndicatorParameters = 38, -// IndicatorRelease = 39, - CopyBuffer = 40, - CopyBuffer1 = 1040, - CopyBuffer2 = 1140, - CopyRates = 41, - CopyRates1 = 1041, - CopyRates2 = 1141, - CopyTime = 42, - CopyTime1 = 1042, - CopyTime2 = 1142, - CopyOpen = 43, - CopyOpen1 = 1043, - CopyOpen2 = 1143, - CopyHigh = 44, - CopyHigh1 = 1044, - CopyHigh2 = 1144, - CopyLow = 45, - CopyLow1 = 1045, - CopyLow2 = 1145, - CopyClose = 46, - CopyClose1 = 1046, - CopyClose2 = 1146, - CopyTickVolume = 47, - CopyTickVolume1 = 1047, - CopyTickVolume2 = 1147, - CopyRealVolume = 48, - CopyRealVolume1 = 1048, - CopyRealVolume2 = 1148, - CopySpread = 49, - CopySpread1 = 1049, - CopySpread2 = 1149, - - //Market Information - SymbolsTotal = 50, - SymbolName = 51, - SymbolSelect = 52, - SymbolIsSynchronized = 53, - SymbolInfoDouble = 54, - SymbolInfoInteger = 55, - SymbolInfoString = 56, - SymbolInfoTick = 57, - SymbolInfoSessionQuote = 58, - SymbolInfoSessionTrade = 59, - MarketBookAdd = 60, - MarketBookRelease = 61, - //MarketBookGet = 62, - OrderCloseAll = 63, - - //CTrade - PositionClose = 64, - PositionOpen = 65, - PositionModify = 6066, - PositionClosePartial_bySymbol = 6067, - PositionClosePartial_byTicket = 6068, - //PositionOpenWithResult = 1065, - - //Backtesting - BacktestingReady = 66, - IsTesting = 67, - - //Requests - MtRequest = 155, - - PositionSelectByTicket = 69, - - ObjectCreate = 70, - ObjectName = 71, - ObjectDelete = 72, - ObjectsDeleteAll = 73, - ObjectFind = 74, - ObjectGetTimeByValue = 75, - ObjectGetValueByTime = 76, - ObjectMove = 77, - ObjectsTotal = 78, - ObjectGetDouble = 79, - ObjectGetInteger = 80, - ObjectGetString = 81, - ObjectSetDouble = 82, - ObjectSetInteger = 83, - ObjectSetString = 84, - //TextSetFont = 85, - //TextOut = 86, - //TextGetSize = 87, - - iAC = 88, - iAD = 89, - iADX = 90, - iADXWilder = 91, - iAlligator = 92, - iAMA = 93, - iAO = 94, - iATR = 95, - iBearsPower = 96, - iBands = 97, - iBullsPower = 98, - iCCI = 99, - iChaikin = 100, - //iCustom = 101, - iDEMA = 102, - iDeMarker = 103, - iEnvelopes = 104, - iForce = 105, - iFractals = 106, - iFrAMA = 107, - iGator = 108, - iIchimoku = 109, - iBWMFI = 110, - iMomentum = 111, - iMFI = 112, - iMA = 113, - iOsMA = 114, - iMACD = 115, - iOBV = 116, - iSAR = 117, - iRSI = 118, - iRVI = 119, - iStdDev = 120, - iStochastic = 121, - iTEMA = 122, - iTriX = 123, - iWPR = 124, - iVIDyA = 125, - iVolumes = 126, - - //Date and Time - TimeCurrent = 127, - TimeTradeServer = 128, - TimeLocal = 129, - TimeGMT = 130, - - IndicatorRelease = 131, - - //Chart Operations - ChartId = 206, - ChartRedraw = 207, - ChartApplyTemplate = 236, - ChartSaveTemplate = 237, - ChartWindowFind = 238, - //ChartTimePriceToXY = 239, - //ChartXYToTimePrice = 240, - ChartOpen = 241, - ChartFirst = 242, - ChartNext = 243, - ChartClose = 244, - ChartSymbol = 245, - ChartPeriod = 246, - ChartSetDouble = 247, - ChartSetInteger = 248, - ChartSetString = 249, - ChartGetDouble = 250, - ChartGetInteger = 251, - ChartGetString = 252, - ChartNavigate = 253, - ChartIndicatorDelete = 254, - ChartIndicatorName = 255, - ChartIndicatorsTotal = 256, - ChartWindowOnDropped = 257, - ChartPriceOnDropped = 258, - ChartTimeOnDropped = 259, - ChartXOnDropped = 260, - ChartYOnDropped = 261, - ChartSetSymbolPeriod = 262, - ChartScreenShot = 263, - ChartIndicatorAdd = 280, - ChartIndicatorGet = 281, - - // Terminal Operations - TerminalCompany = 68, - TerminalName = 69, - TerminalPath = 70, - - //Checkup - GetLastError = 132, - TerminalInfoString = 153, - TerminalInfoInteger = 204, - TerminalInfoDouble = 205, - - //Common Functions - Alert = 136, - Comment = 137, //TODO - GetTickCount = 138, //TODO - GetMicrosecondCount = 139, //TODO - MessageBox = 140, //TODO - PeriodSeconds = 141, //TODO - PlaySound = 142, //TODO - Print = 68, - ResetLastError = 143, - SendNotification = 144, //TODO - SendMail = 145, //TODO - - //Global Variables - GlobalVariableCheck = 146, - GlobalVariableTime = 147, - GlobalVariableDel = 148, - GlobalVariableGet = 149, - GlobalVariableName = 150, - GlobalVariableSet = 151, - GlobalVariablesFlush = 152, - GlobalVariableTemp = 154, - GlobalVariableSetOnCondition = 156, - GlobalVariablesDeleteAll = 157, - GlobalVariablesTotal = 158, - - UnlockTicks = 159, - PositionCloseAll = 160, - TesterStop = 161 - } -} diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs index 5c4ffbe8..f7fd45e5 100755 --- a/MtApi5/MtApi5Client.cs +++ b/MtApi5/MtApi5Client.cs @@ -1,10 +1,10 @@ using System.Collections; using MtApi5.Requests; using Newtonsoft.Json; -using MtApi5.Events; using MtClient; -using System.Reflection.Metadata; -using System.Collections.Generic; +using MtApi5.MtProtocol; +using System.Linq; +using System.Net.Http.Headers; namespace MtApi5 { @@ -265,11 +265,12 @@ namespace MtApi5 ///Returns the symbol corresponding to the open position and automatically selects the position for further working with it using functions PositionGetDouble, PositionGetInteger, PositionGetString. /// ///Number of the position in the list of open positions. - public string PositionGetSymbol(int index) + public string? PositionGetSymbol(int index) { - var commandParameters = new ArrayList { index }; + Dictionary commandParameters = []; + commandParameters["Index"] = index; - return SendCommand(Mt5CommandType.PositionGetSymbol, commandParameters); + return SendCommand(ExecutorHandle, Mt5CommandType.PositionGetSymbol, commandParameters); } /// @@ -789,9 +790,8 @@ namespace MtApi5 ///Identifier of the property. public double AccountInfoDouble(ENUM_ACCOUNT_INFO_DOUBLE propertyId) { - var commandParameters = new ArrayList { (int)propertyId }; - - return SendCommand(Mt5CommandType.AccountInfoDouble, commandParameters); + Dictionary commandParameters = new() { { "PropertyId", propertyId } }; + return SendCommand(ExecutorHandle, Mt5CommandType.AccountInfoDouble, commandParameters); } /// @@ -800,20 +800,18 @@ namespace MtApi5 ///Identifier of the property. public long AccountInfoInteger(ENUM_ACCOUNT_INFO_INTEGER propertyId) { - var commandParameters = new ArrayList { (int)propertyId }; - - return SendCommand(Mt5CommandType.AccountInfoInteger, commandParameters); + Dictionary commandParameters = new() { { "PropertyId", propertyId } }; + return SendCommand(ExecutorHandle, Mt5CommandType.AccountInfoInteger, commandParameters); } /// ///Returns the value of the corresponding account property. /// ///Identifier of the property. - public string AccountInfoString(ENUM_ACCOUNT_INFO_STRING propertyId) + public string? AccountInfoString(ENUM_ACCOUNT_INFO_STRING propertyId) { - var commandParameters = new ArrayList { (int)propertyId }; - - return SendCommand(Mt5CommandType.AccountInfoString, commandParameters); + Dictionary commandParameters = new() { { "PropertyId", propertyId } }; + return SendCommand(ExecutorHandle, Mt5CommandType.AccountInfoString, commandParameters); } #endregion @@ -3424,6 +3422,8 @@ namespace MtApi5 { _experts = experts; _quotes = quotes; + if (_executorHandle == 0) + _executorHandle = (_experts.Count > 0) ? _experts.ElementAt(0) : 0; } _quotesWaiter.Set(); @@ -3470,6 +3470,9 @@ namespace MtApi5 _experts.Remove(handle); if (_quotes.TryGetValue(handle, out quote)) _quotes.Remove(handle); + if (_executorHandle == handle) + _executorHandle = (_experts.Count > 0) ? _experts.ElementAt(0) : 0; + } if (quote != null) @@ -3480,19 +3483,19 @@ namespace MtApi5 { Log?.Debug($"GetQuote: expertHandle = {expertHandle}"); - var e = SendCommand(expertHandle, Mt5CommandType.GetQuote); + var e = SendCommand(expertHandle, Mt5CommandType.GetQuote); if (e == null || string.IsNullOrEmpty(e.Instrument) || e.Tick == null) return null; Mt5Quote quote = new() { Instrument = e.Instrument, - Bid = e.Tick.bid, - Ask = e.Tick.ask, + Bid = e.Tick.Bid, + Ask = e.Tick.Ask, ExpertHandle = expertHandle, - Volume = e.Tick.volume, - Time = e.Tick.time, - Last = e.Tick.last + Volume = e.Tick.Volume, + Time = Mt5TimeConverter.ConvertFromMtTime(e.Tick.Time), + Last = e.Tick.Last }; return quote; @@ -3510,62 +3513,62 @@ namespace MtApi5 Disconnect(false); } - private void ReceivedOnTradeTransactionEvent(int expertHandler, string payload) + private void ReceivedOnTradeTransactionEvent(int expertHandle, string payload) { var e = JsonConvert.DeserializeObject(payload); if (e == null) return; OnTradeTransaction?.Invoke(this, new Mt5TradeTransactionEventArgs { - ExpertHandle = expertHandler, + ExpertHandle = expertHandle, Trans = e.Trans, Request = e.Request, Result = e.Result }); } - private void ReceivedOnBookEvent(int expertHandler, string payload) + private void ReceivedOnBookEvent(int expertHandle, string payload) { var e = JsonConvert.DeserializeObject(payload); if (e == null || string.IsNullOrEmpty(e.Symbol)) return; OnBookEvent?.Invoke(this, new Mt5BookEventArgs { - ExpertHandle = expertHandler, + ExpertHandle = expertHandle, Symbol = e.Symbol }); } - private void ReceivedOnTickEvent(int expertHandler, string payload) + private void ReceivedOnTickEvent(int expertHandle, string payload) { - var e = JsonConvert.DeserializeObject(payload); + var e = JsonConvert.DeserializeObject(payload); if (e == null || string.IsNullOrEmpty(e.Instrument) || e.Tick == null) return; - QuoteUpdated?.Invoke(this, e.Instrument, e.Tick.bid, e.Tick.ask); + QuoteUpdated?.Invoke(this, e.Instrument, e.Tick.Bid, e.Tick.Ask); Mt5Quote quote = new() { Instrument = e.Instrument, - Bid = e.Tick.bid, - Ask = e.Tick.ask, - ExpertHandle = expertHandler, - Volume = e.Tick.volume, - Time = e.Tick.time, - Last = e.Tick.last + Bid = e.Tick.Bid, + Ask = e.Tick.Ask, + ExpertHandle = expertHandle, + Volume = e.Tick.Volume, + Time = Mt5TimeConverter.ConvertFromMtTime(e.Tick.Time), + Last = e.Tick.Last }; QuoteUpdate?.Invoke(this, new Mt5QuoteEventArgs(quote)); } - private void ReceivedOnLastTimeBarEvent(int expertHandler, string payload) + private void ReceivedOnLastTimeBarEvent(int expertHandle, string payload) { var e = JsonConvert.DeserializeObject(payload); if (e == null || string.IsNullOrEmpty(e.Instrument) || e.Rates == null) return; - OnLastTimeBar?.Invoke(this, new Mt5TimeBarArgs(expertHandler, e.Instrument, e.Rates)); + OnLastTimeBar?.Invoke(this, new Mt5TimeBarArgs(expertHandle, e.Instrument, e.Rates)); } - private void ReceivedOnLockTicksEvent(int expertHandler, string payload) + private void ReceivedOnLockTicksEvent(int expertHandle, string payload) { var e = JsonConvert.DeserializeObject(payload); if (e == null || string.IsNullOrEmpty(e.Instrument)) @@ -3592,6 +3595,7 @@ namespace MtApi5 _quotes.Clear(); _experts.Clear(); + _executorHandle = 0; } client?.Disconnect(); diff --git a/MtApi5/MtProtocol/FuncResult.cs b/MtApi5/MtProtocol/FuncResult.cs new file mode 100755 index 00000000..e7739af7 --- /dev/null +++ b/MtApi5/MtProtocol/FuncResult.cs @@ -0,0 +1,8 @@ +namespace MtApi5.MtProtocol +{ + internal class FuncResult + { + public bool RetVal { get; set; } + public T? Result { get; set; } + } +} diff --git a/MtApi5/MtProtocol/MqlTick.cs b/MtApi5/MtProtocol/MqlTick.cs new file mode 100755 index 00000000..a3b463bb --- /dev/null +++ b/MtApi5/MtProtocol/MqlTick.cs @@ -0,0 +1,12 @@ +namespace MtApi5.MtProtocol +{ + public class MtTick + { + public double Bid { get; set; } // Current Bid price + public double Ask { get; set; } // Current Ask price + public long Time { get; set; } // Time of the last prices update + public double Last { get; set; } // Price of the last deal (Last) + public ulong Volume { get; set; } // Volume for the current Last price + public double VolumeReal { get; set; } // Volume for the current Last price with greater accuracy + } +} \ No newline at end of file diff --git a/MtApi5/MtProtocol/Mt5CommandType.cs b/MtApi5/MtProtocol/Mt5CommandType.cs new file mode 100755 index 00000000..078bfb4a --- /dev/null +++ b/MtApi5/MtProtocol/Mt5CommandType.cs @@ -0,0 +1,260 @@ +// ReSharper disable InconsistentNaming +namespace MtApi5.MtProtocol +{ + internal enum Mt5CommandType + { + //NoCommand = 0 + + GetQuote = 1, + //trade operations + OrderCalcMargin = 2, + OrderCalcProfit = 3, + //OrderSendAsync = 5, + PositionsTotal = 6, + PositionGetSymbol = 7, + PositionSelect = 8, + PositionGetDouble = 9, + PositionGetInteger = 10, + PositionGetString = 11, + PositionGetTicket = 4, + OrdersTotal = 12, + OrderGetTicket = 13, + OrderSelect = 14, + OrderGetDouble = 15, + OrderGetInteger = 16, + OrderGetString = 17, + HistorySelect = 18, + HistorySelectByPosition = 19, + HistoryOrderSelect = 20, + HistoryOrdersTotal = 21, + HistoryOrderGetTicket = 22, + HistoryOrderGetDouble = 23, + HistoryOrderGetInteger = 24, + HistoryOrderGetString = 25, + HistoryDealSelect = 26, + HistoryDealsTotal = 27, + HistoryDealGetTicket = 28, + HistoryDealGetDouble = 29, + HistoryDealGetInteger = 30, + HistoryDealGetString = 31, + + //Account Information + AccountInfoDouble = 32, + AccountInfoInteger = 33, + AccountInfoString = 34, + + //Access to Timeseries and Indicator Data + SeriesInfoInteger = 35, + Bars = 36, + Bars2 = 1036, + BarsCalculated = 37, + // IndicatorCreate = 38, + // IndicatorParameters = 38, + // IndicatorRelease = 39, + CopyBuffer = 40, + CopyBuffer1 = 1040, + CopyBuffer2 = 1140, + CopyRates = 41, + CopyRates1 = 1041, + CopyRates2 = 1141, + CopyTime = 42, + CopyTime1 = 1042, + CopyTime2 = 1142, + CopyOpen = 43, + CopyOpen1 = 1043, + CopyOpen2 = 1143, + CopyHigh = 44, + CopyHigh1 = 1044, + CopyHigh2 = 1144, + CopyLow = 45, + CopyLow1 = 1045, + CopyLow2 = 1145, + CopyClose = 46, + CopyClose1 = 1046, + CopyClose2 = 1146, + CopyTickVolume = 47, + CopyTickVolume1 = 1047, + CopyTickVolume2 = 1147, + CopyRealVolume = 48, + CopyRealVolume1 = 1048, + CopyRealVolume2 = 1148, + CopySpread = 49, + CopySpread1 = 1049, + CopySpread2 = 1149, + + //Market Information + SymbolsTotal = 50, + SymbolName = 51, + SymbolSelect = 52, + SymbolIsSynchronized = 53, + SymbolInfoDouble = 54, + SymbolInfoInteger = 55, + SymbolInfoString = 56, + SymbolInfoTick = 57, + SymbolInfoSessionQuote = 58, + SymbolInfoSessionTrade = 59, + MarketBookAdd = 60, + MarketBookRelease = 61, + //MarketBookGet = 62, + OrderCloseAll = 63, + + //CTrade + PositionClose = 64, + PositionOpen = 65, + PositionModify = 6066, + PositionClosePartial_bySymbol = 6067, + PositionClosePartial_byTicket = 6068, + //PositionOpenWithResult = 1065, + + //Backtesting + BacktestingReady = 66, + IsTesting = 67, + + //Requests + MtRequest = 155, + + PositionSelectByTicket = 69, + + ObjectCreate = 70, + ObjectName = 71, + ObjectDelete = 72, + ObjectsDeleteAll = 73, + ObjectFind = 74, + ObjectGetTimeByValue = 75, + ObjectGetValueByTime = 76, + ObjectMove = 77, + ObjectsTotal = 78, + ObjectGetDouble = 79, + ObjectGetInteger = 80, + ObjectGetString = 81, + ObjectSetDouble = 82, + ObjectSetInteger = 83, + ObjectSetString = 84, + //TextSetFont = 85, + //TextOut = 86, + //TextGetSize = 87, + + iAC = 88, + iAD = 89, + iADX = 90, + iADXWilder = 91, + iAlligator = 92, + iAMA = 93, + iAO = 94, + iATR = 95, + iBearsPower = 96, + iBands = 97, + iBullsPower = 98, + iCCI = 99, + iChaikin = 100, + //iCustom = 101, + iDEMA = 102, + iDeMarker = 103, + iEnvelopes = 104, + iForce = 105, + iFractals = 106, + iFrAMA = 107, + iGator = 108, + iIchimoku = 109, + iBWMFI = 110, + iMomentum = 111, + iMFI = 112, + iMA = 113, + iOsMA = 114, + iMACD = 115, + iOBV = 116, + iSAR = 117, + iRSI = 118, + iRVI = 119, + iStdDev = 120, + iStochastic = 121, + iTEMA = 122, + iTriX = 123, + iWPR = 124, + iVIDyA = 125, + iVolumes = 126, + + //Date and Time + TimeCurrent = 127, + TimeTradeServer = 128, + TimeLocal = 129, + TimeGMT = 130, + + IndicatorRelease = 131, + + //Chart Operations + ChartId = 206, + ChartRedraw = 207, + ChartApplyTemplate = 236, + ChartSaveTemplate = 237, + ChartWindowFind = 238, + //ChartTimePriceToXY = 239, + //ChartXYToTimePrice = 240, + ChartOpen = 241, + ChartFirst = 242, + ChartNext = 243, + ChartClose = 244, + ChartSymbol = 245, + ChartPeriod = 246, + ChartSetDouble = 247, + ChartSetInteger = 248, + ChartSetString = 249, + ChartGetDouble = 250, + ChartGetInteger = 251, + ChartGetString = 252, + ChartNavigate = 253, + ChartIndicatorDelete = 254, + ChartIndicatorName = 255, + ChartIndicatorsTotal = 256, + ChartWindowOnDropped = 257, + ChartPriceOnDropped = 258, + ChartTimeOnDropped = 259, + ChartXOnDropped = 260, + ChartYOnDropped = 261, + ChartSetSymbolPeriod = 262, + ChartScreenShot = 263, + ChartIndicatorAdd = 280, + ChartIndicatorGet = 281, + + // Terminal Operations + TerminalCompany = 68, + TerminalName = 69, + TerminalPath = 70, + + //Checkup + GetLastError = 132, + TerminalInfoString = 153, + TerminalInfoInteger = 204, + TerminalInfoDouble = 205, + + //Common Functions + Alert = 136, + Comment = 137, //TODO + GetTickCount = 138, //TODO + GetMicrosecondCount = 139, //TODO + MessageBox = 140, //TODO + PeriodSeconds = 141, //TODO + PlaySound = 142, //TODO + Print = 68, + ResetLastError = 143, + SendNotification = 144, //TODO + SendMail = 145, //TODO + + //Global Variables + GlobalVariableCheck = 146, + GlobalVariableTime = 147, + GlobalVariableDel = 148, + GlobalVariableGet = 149, + GlobalVariableName = 150, + GlobalVariableSet = 151, + GlobalVariablesFlush = 152, + GlobalVariableTemp = 154, + GlobalVariableSetOnCondition = 156, + GlobalVariablesDeleteAll = 157, + GlobalVariablesTotal = 158, + + UnlockTicks = 159, + PositionCloseAll = 160, + TesterStop = 161 + } +} diff --git a/MtApi5/MtProtocol/Mt5EventTypes.cs b/MtApi5/MtProtocol/Mt5EventTypes.cs new file mode 100755 index 00000000..00284b5b --- /dev/null +++ b/MtApi5/MtProtocol/Mt5EventTypes.cs @@ -0,0 +1,11 @@ +namespace MtApi5.MtProtocol +{ + internal enum Mt5EventTypes + { + OnTradeTransaction = 1, + OnBookEvent = 2, + OnTick = 3, + OnLastTimeBar = 4, + OnLockTicks = 5 + } +} diff --git a/MtApi5/Events/OnTickEvent.cs b/MtApi5/MtProtocol/MtQuote.cs old mode 100644 new mode 100755 similarity index 50% rename from MtApi5/Events/OnTickEvent.cs rename to MtApi5/MtProtocol/MtQuote.cs index e7874644..7261e417 --- a/MtApi5/Events/OnTickEvent.cs +++ b/MtApi5/MtProtocol/MtQuote.cs @@ -1,8 +1,8 @@ -namespace MtApi5.Events +namespace MtApi5.MtProtocol { - internal class OnTickEvent + internal class MtQuote { - public MqlTick? Tick { get; set; } + public MtTick? Tick { get; set; } public string? Instrument { get; set; } public int ExpertHandle { get; set; } } diff --git a/MtApi5/Events/OnBookEvent.cs b/MtApi5/MtProtocol/OnBookEvent.cs old mode 100644 new mode 100755 similarity index 70% rename from MtApi5/Events/OnBookEvent.cs rename to MtApi5/MtProtocol/OnBookEvent.cs index 8657dca3..754d0507 --- a/MtApi5/Events/OnBookEvent.cs +++ b/MtApi5/MtProtocol/OnBookEvent.cs @@ -1,4 +1,4 @@ -namespace MtApi5.Events +namespace MtApi5.MtProtocol { internal class OnBookEvent { diff --git a/MtApi5/Events/OnLastTimeBarEvent.cs b/MtApi5/MtProtocol/OnLastTimeBarEvent.cs old mode 100644 new mode 100755 similarity index 66% rename from MtApi5/Events/OnLastTimeBarEvent.cs rename to MtApi5/MtProtocol/OnLastTimeBarEvent.cs index 3a0178e1..de07ff8e --- a/MtApi5/Events/OnLastTimeBarEvent.cs +++ b/MtApi5/MtProtocol/OnLastTimeBarEvent.cs @@ -1,6 +1,6 @@ -namespace MtApi5.Events +namespace MtApi5.MtProtocol { - public class OnLastTimeBarEvent + internal class OnLastTimeBarEvent { public MqlRates? Rates { get; set; } public string? Instrument { get; set; } diff --git a/MtApi5/Events/OnLockTicksEvent.cs b/MtApi5/MtProtocol/OnLockTicksEvent.cs old mode 100644 new mode 100755 similarity index 72% rename from MtApi5/Events/OnLockTicksEvent.cs rename to MtApi5/MtProtocol/OnLockTicksEvent.cs index 7b6297df..5a5cbe9d --- a/MtApi5/Events/OnLockTicksEvent.cs +++ b/MtApi5/MtProtocol/OnLockTicksEvent.cs @@ -1,4 +1,4 @@ -namespace MtApi5.Events +namespace MtApi5.MtProtocol { internal class OnLockTicksEvent { diff --git a/MtApi5/Events/OnTradeTransactionEvent.cs b/MtApi5/MtProtocol/OnTradeTransactionEvent.cs old mode 100644 new mode 100755 similarity index 84% rename from MtApi5/Events/OnTradeTransactionEvent.cs rename to MtApi5/MtProtocol/OnTradeTransactionEvent.cs index c812ccf9..b4f3ed71 --- a/MtApi5/Events/OnTradeTransactionEvent.cs +++ b/MtApi5/MtProtocol/OnTradeTransactionEvent.cs @@ -1,4 +1,4 @@ -namespace MtApi5.Events +namespace MtApi5.MtProtocol { internal class OnTradeTransactionEvent { diff --git a/MtApi5/Requests/Response.cs b/MtApi5/MtProtocol/Response.cs old mode 100644 new mode 100755 similarity index 81% rename from MtApi5/Requests/Response.cs rename to MtApi5/MtProtocol/Response.cs index 668a0890..0c9c8217 --- a/MtApi5/Requests/Response.cs +++ b/MtApi5/MtProtocol/Response.cs @@ -1,4 +1,4 @@ -namespace MtApi5.Requests +namespace MtApi5.MtProtocol { internal class Response {