- Add some commands to handle with Chart to MT5 api

- Add some commands to handle with windows to MT5 api
This commit is contained in:
Janderson FFerreira
2018-03-11 19:26:25 -03:00
parent d7b8ef894c
commit 6a37826486
7 changed files with 897 additions and 7 deletions
+74
View File
@@ -7,6 +7,7 @@ using MtApi5;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Threading.Tasks;
using System.IO;
namespace MtApi5TestClient
{
@@ -64,11 +65,79 @@ namespace MtApi5TestClient
public DelegateCommand iCustomCommand { get; private set; }
public DelegateCommand TimeCurrentCommand { get; private set; }
public DelegateCommand ChartOpenCommand { get; private set; }
public DelegateCommand ChartApplyTemplateCommand { get; private set; }
public DelegateCommand TimeTradeServerCommand { get; private set; }
public DelegateCommand TimeLocalCommand { get; private set; }
public DelegateCommand TimeGMTCommand { get; private set; }
#endregion
#region Chart Commands
private async void ExecuteChartOpen(object o)
{
AddLog("Executed #1");
if (string.IsNullOrEmpty(TimeSeriesValues?.SymbolValue)) return;
AddLog($"Executed #2 s:{TimeSeriesValues?.SymbolValue}");
var result = await Execute(() =>
{
var SymbolAddReturn = _mtApiClient.SymbolSelect(TimeSeriesValues?.SymbolValue, true);
var ChartId = _mtApiClient.ChartOpen(TimeSeriesValues?.SymbolValue, TimeSeriesValues.TimeFrame);
return ChartId;
});
if (result == -1)
{
AddLog("ChartOpen: result is null");
return;
}
AddLog($"ChartOpen: success chartid=>{result}");
}
private async void ExecuteChartApplyTemplate(object o)
{
AddLog("Executed #1");
if (string.IsNullOrEmpty(TimeSeriesValues?.SymbolValue)) return;
AddLog($"Executed #2 s:{TimeSeriesValues?.SymbolValue}");
var result = await Execute(() =>
{
var SymbolAddReturn = _mtApiClient.SymbolSelect(TimeSeriesValues?.SymbolValue, true);
var ChartId = _mtApiClient.ChartOpen(TimeSeriesValues?.SymbolValue, TimeSeriesValues.TimeFrame);
var MT5Path = _mtApiClient.TerminalInfoString(ENUM_TERMINAL_INFO_STRING.TERMINAL_PATH);
var TemplateName = "\\Files\\aa.tpl";
var TemplateStringContent = File.ReadAllLines("d:\\template_name.tpl");
File.WriteAllLines($"{MT5Path}\\MQL5{TemplateName}", TemplateStringContent);
AddLog($"path: {MT5Path}");
_mtApiClient.ChartApplyTemplate(ChartId, TemplateName);
//var Applytemplate = _mtApiClient.ChartApplyTemplate(ChartId, "/")
return ChartId;
});
if (result == -1)
{
AddLog("ChartOpen: result is null");
return;
}
AddLog($"ChartOpen: success chartid=>{result}");
}
#endregion
#region Properties
private Mt5ConnectionState _connectionState;
public Mt5ConnectionState ConnectionState
@@ -258,6 +327,10 @@ namespace MtApi5TestClient
iCustomCommand = new DelegateCommand(ExecuteICustom);
ChartOpenCommand = new DelegateCommand(ExecuteChartOpen);
ChartApplyTemplateCommand = new DelegateCommand(ExecuteChartApplyTemplate);
TimeCurrentCommand = new DelegateCommand(ExecuteTimeCurrent);
TimeTradeServerCommand = new DelegateCommand(ExecuteTimeTradeServer);
TimeLocalCommand = new DelegateCommand(ExecuteTimeLocal);
@@ -1108,6 +1181,7 @@ namespace MtApi5TestClient
});
}
private void AddLog(string msg)
{
RunOnUiThread(() =>