Issue #209: [MT5] Added function ChartId to get chart id by expert handle.

This commit is contained in:
Viacheslav Demydiuk
2020-10-25 19:20:44 +02:00
parent 60c8a646ff
commit 318bae3852
3 changed files with 33 additions and 2 deletions
+14 -2
View File
@@ -1717,6 +1717,18 @@ namespace MtApi5
return SendCommand<long>(Mt5CommandType.ChartId, null);
}
///<summary>
///Returns the ID of the chart.
///</summary>
///<param name="expertHandle">Handle of expert linked to the chart.</param>
///<returns>
/// Value of long type.
///</returns>
public long ChartId(int expertHandle)
{
return SendCommand<long>(Mt5CommandType.ChartId, null, null, expertHandle);
}
///<summary>
///This function calls a forced redrawing of a specified chart.
///</summary>
@@ -3468,7 +3480,7 @@ namespace MtApi5
ConnectionStateChanged?.Invoke(this, new Mt5ConnectionEventArgs(state, message));
}
private T SendCommand<T>(Mt5CommandType commandType, ArrayList commandParameters, Dictionary<string, object> namedParams = null)
private T SendCommand<T>(Mt5CommandType commandType, ArrayList commandParameters, Dictionary<string, object> namedParams = null, int? executor = null)
{
MtResponse response;
@@ -3480,7 +3492,7 @@ namespace MtApi5
try
{
response = client.SendCommand((int)commandType, commandParameters, namedParams, ExecutorHandle);
response = client.SendCommand((int)commandType, commandParameters, namedParams, executor ?? ExecutorHandle);
}
catch (CommunicationException ex)
{
@@ -542,6 +542,7 @@
<StackPanel Grid.Row="4" Orientation="Horizontal" Margin="5">
<Button Command="{Binding ChartIdCommand}" Content="ChartId" Margin="2"/>
<Button Command="{Binding ChartIdByExpertHandleCommand}" Content="ChartId by ExpertHandle" Margin="2"/>
<TextBlock Text="ChartID" VerticalAlignment="Center" Margin="20,2,2,2"/>
<TextBox Width="150" Text="{Binding ChartFunctionsChartIdValue}" Margin="2"/>
</StackPanel>
+18
View File
@@ -90,6 +90,7 @@ namespace MtApi5TestClient
public DelegateCommand ChartApplyTemplateCommand { get; private set; }
public DelegateCommand ChartSaveTemplateCommand { get; private set; }
public DelegateCommand ChartIdCommand { get; private set; }
public DelegateCommand ChartIdByExpertHandleCommand { get; private set; }
public DelegateCommand ChartRedrawCommand { get; private set; }
public DelegateCommand ChartWindowFindCommand { get; private set; }
public DelegateCommand ChartCloseCommand { get; private set; }
@@ -403,6 +404,7 @@ namespace MtApi5TestClient
ChartApplyTemplateCommand = new DelegateCommand(ExecuteChartApplyTemplate);
ChartSaveTemplateCommand = new DelegateCommand(ExecuteChartSaveTemplate);
ChartIdCommand = new DelegateCommand(ExecuteChartId);
ChartIdByExpertHandleCommand = new DelegateCommand(ExecuteChartIdByExpertHandle);
ChartRedrawCommand = new DelegateCommand(ExecuteChartRedraw);
ChartWindowFindCommand = new DelegateCommand(ExecuteChartWindowFind);
ChartCloseCommand = new DelegateCommand(ExecuteChartClose);
@@ -1514,6 +1516,22 @@ namespace MtApi5TestClient
AddLog($"ChartId: chartid = {result}");
}
private async void ExecuteChartIdByExpertHandle(object o)
{
if (SelectedQuote == null)
{
AddLog("Instrument is not selected.");
return;
}
var result = await Execute(() => _mtApiClient.ChartId(SelectedQuote.ExpertHandle));
RunOnUiThread(() =>
{
ChartFunctionsChartIdValue = result;
});
AddLog($"ChartIdByExpertHandle: chartid = {result}");
}
private void ExecuteChartRedraw(object o)
{
var chartId = ChartFunctionsChartIdValue;