Issue #100: implemented second function SymbolInfoString (MT5)

This commit is contained in:
vdemydiuk
2018-03-13 11:20:55 +02:00
parent bce68fd168
commit 93aaae86ed
9 changed files with 350 additions and 298 deletions
+49 -49
View File
@@ -182,59 +182,59 @@ namespace MtApi5
//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,
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,
// Windows Operations
WindowBarsPerChart = 264,
WindowExpertName = 265,
WindowFind = 266,
WindowFirstVisibleBar = 267,
WindowHandle = 268,
WindowIsVisible = 269,
WindowOnDropped = 270,
WindowPriceMax = 271,
WindowPriceMin = 272,
WindowPriceOnDropped = 273,
WindowRedraw = 274,
WindowScreenShot = 275,
WindowTimeOnDropped = 276,
WindowsTotal = 277,
WindowXOnDropped = 278,
WindowYOnDropped = 279,
WindowBarsPerChart = 264,
WindowExpertName = 265,
WindowFind = 266,
WindowFirstVisibleBar = 267,
WindowHandle = 268,
WindowIsVisible = 269,
WindowOnDropped = 270,
WindowPriceMax = 271,
WindowPriceMin = 272,
WindowPriceOnDropped = 273,
WindowRedraw = 274,
WindowScreenShot = 275,
WindowTimeOnDropped = 276,
WindowsTotal = 277,
WindowXOnDropped = 278,
WindowYOnDropped = 279,
// Terminal Operations
TerminalCompany = 68,
TerminalName = 69,
TerminalPath = 70,
TerminalCompany = 68,
TerminalName = 69,
TerminalPath = 70,
//Checkup
GetLastError = 132,
+4 -3
View File
@@ -16,12 +16,13 @@ namespace MtApi5
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
}
public static int ConvertToMtTime(DateTime time)
public static int ConvertToMtTime(DateTime? time)
{
var result = 0;
if (time == DateTime.MinValue) return result;
if (time == null || time == DateTime.MinValue)
return result;
var tmpTime = new DateTime(1970, 1, 1);
result = (int)((time.Ticks - tmpTime.Ticks) / 0x989680L);
result = (int)((time.Value.Ticks - tmpTime.Ticks) / 0x989680L);
return result;
}
}
+2
View File
@@ -85,6 +85,8 @@
<Compile Include="Requests\RequestType.cs" />
<Compile Include="Requests\OrderSendResult.cs" />
<Compile Include="Requests\Response.cs" />
<Compile Include="Requests\SymbolInfoStringRequest.cs" />
<Compile Include="Requests\SymbolInfoStringResult.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MTApiService\MTApiService.csproj">
+18 -1
View File
@@ -1386,6 +1386,23 @@ namespace MtApi5
return SendCommand<string>(Mt5CommandType.SymbolInfoString, commandParameters);
}
///<summary>
///Returns the corresponding property of a specified symbol.
///</summary>
///<param name="symbolName">Symbol name.</param>
///<param name="propId">Identifier of a symbol property.</param>
///<param name="value">Variable of the string type receiving the value of the requested property.</param>
public bool SymbolInfoString(string symbolName, ENUM_SYMBOL_INFO_STRING propId, out string value)
{
var response = SendRequest<SymbolInfoStringResult>(new SymbolInfoStringRequest
{
SymbolName = symbolName,
PropId = propId
});
value = response?.StringVar;
return response?.RetVal ?? false;
}
///<summary>
///The function returns current prices of a specified symbol in a variable of the MqlTick type.
@@ -1561,7 +1578,7 @@ namespace MtApi5
///</returns>
public bool ChartTimePriceToXY(long chartId, int subWindow, DateTime? time, double price, out int x, out int y)
{
var commandParameters = new ArrayList { chartId, subWindow, Mt5TimeConverter.ConvertToMtTime((DateTime)time), price };
var commandParameters = new ArrayList { chartId, subWindow, Mt5TimeConverter.ConvertToMtTime(time), price };
var str = SendCommand<string>(Mt5CommandType.ChartTimePriceToXY, commandParameters);
var res = false;
x = 0;
+9 -8
View File
@@ -4,13 +4,14 @@ namespace MtApi5.Requests
{
internal enum RequestType
{
Unknown = 0,
CopyTicks = 1,
iCustom = 2,
OrderSend = 3,
PositionOpen = 4,
OrderCheck = 5,
MarketBookGet = 6,
IndicatorCreate = 7
Unknown = 0,
CopyTicks = 1,
iCustom = 2,
OrderSend = 3,
PositionOpen = 4,
OrderCheck = 5,
MarketBookGet = 6,
IndicatorCreate = 7,
SymbolInfoString = 8
}
}
@@ -0,0 +1,10 @@
namespace MtApi5.Requests
{
internal class SymbolInfoStringRequest : RequestBase
{
public override RequestType RequestType => RequestType.SymbolInfoString;
public string SymbolName { get; set; }
public ENUM_SYMBOL_INFO_STRING PropId { get; set; }
}
}
@@ -0,0 +1,8 @@
namespace MtApi5.Requests
{
internal class SymbolInfoStringResult
{
public bool RetVal { get; set; }
public string StringVar { get; set; }
}
}