mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 02:57:56 +00:00
Merge pull request #104 from Janderson/master
TerminalInfo Commands and ChartTemplate Commands
This commit is contained in:
@@ -2108,7 +2108,7 @@ namespace MtApi5
|
||||
|
||||
#region Commands of Terminal
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the mql4 program environment.
|
||||
///Returns the value of a corresponding property of the mql5 program environment.
|
||||
///</summary>
|
||||
///<param name="propertyId">Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_STRING enumeration.</param>
|
||||
///<returns>
|
||||
@@ -2121,7 +2121,7 @@ namespace MtApi5
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the mql4 program environment.
|
||||
///Returns the value of a corresponding property of the mql5 program environment.
|
||||
///</summary>
|
||||
///<param name="propertyId">Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_INTEGER enumeration.</param>
|
||||
///<returns>
|
||||
@@ -2134,7 +2134,7 @@ namespace MtApi5
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the mql4 program environment.
|
||||
///Returns the value of a corresponding property of the mql5 program environment.
|
||||
///</summary>
|
||||
///<param name="propertyId">Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_DOUBLE enumeration.</param>
|
||||
///<returns>
|
||||
|
||||
@@ -78,6 +78,28 @@
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
|
||||
<ObjectDataProvider x:Key="ENUM_TERMINAL_INFO_INTEGER_Key" MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="mtapi5:ENUM_TERMINAL_INFO_INTEGER"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
|
||||
<ObjectDataProvider x:Key="ENUM_TERMINAL_INFO_STRING_Key" MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="mtapi5:ENUM_TERMINAL_INFO_STRING"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
|
||||
<ObjectDataProvider x:Key="ENUM_TERMINAL_INFO_DOUBLE_Key" MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="mtapi5:ENUM_TERMINAL_INFO_DOUBLE"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
|
||||
|
||||
<ObjectDataProvider x:Key="ENUM_TIMEFRAMES_Key" MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
@@ -297,6 +319,47 @@
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Terminal Information">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0" Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.4*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ComboBox Grid.Column="0" Grid.Row="0"
|
||||
SelectedItem="{Binding TerminalInfoDoublePropertyId}"
|
||||
ItemsSource="{Binding Source={StaticResource ENUM_TERMINAL_INFO_DOUBLE_Key}}"/>
|
||||
<Button Grid.Column="1" Grid.Row="0" Margin="10,0,0,0"
|
||||
Command="{Binding TerminalInfoDoubleCommand}"
|
||||
Content="TerminalInfoDouble" HorizontalAlignment="Left" />
|
||||
|
||||
<ComboBox Grid.Column="0" Grid.Row="1"
|
||||
SelectedItem="{Binding TerminalInfoIntegerPropertyId}"
|
||||
ItemsSource="{Binding Source={StaticResource ENUM_TERMINAL_INFO_INTEGER_Key}}"/>
|
||||
<Button Grid.Column="1" Grid.Row="1" Margin="10,0,0,0"
|
||||
Command="{Binding TerminalInfoIntegerCommand}"
|
||||
Content="TerminalInfoInteger" HorizontalAlignment="Left" />
|
||||
|
||||
<ComboBox Grid.Column="0" Grid.Row="2"
|
||||
SelectedItem="{Binding TerminalInfoStringPropertyId}"
|
||||
ItemsSource="{Binding Source={StaticResource ENUM_TERMINAL_INFO_STRING_Key}}"/>
|
||||
<Button Grid.Column="1" Grid.Row="2" Margin="10,0,0,0"
|
||||
Command="{Binding TerminalInfoStringCommand}"
|
||||
Content="TerminalInfoString" HorizontalAlignment="Left" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Timeseries and Indicators Access">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -416,10 +479,11 @@
|
||||
</WrapPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="Chart Functions">
|
||||
<WrapPanel>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TimeSeriesValues.SymbolValue}" Margin="1"/>
|
||||
<Button Command="{Binding ChartOpenCommand}" Content="ChartOpen"/>
|
||||
<WrapPanel VerticalAlignment="Top" Margin="5">
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TimeSeriesValues.SymbolValue}" Margin="1"/>
|
||||
<Button Command="{Binding ChartOpenCommand}" Content="ChartOpen"/>
|
||||
<Button Command="{Binding ChartApplyTemplateCommand}" Content="ChartApplyTemplate"/>
|
||||
<Button Command="{Binding ChartSaveTemplateCommand}" Content="ChartSaveTemplate"/>
|
||||
</WrapPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="Time and Date">
|
||||
|
||||
@@ -32,6 +32,10 @@ namespace MtApi5TestClient
|
||||
public DelegateCommand AccountInfoIntegerCommand { get; private set; }
|
||||
public DelegateCommand AccountInfoStringCommand { get; private set; }
|
||||
|
||||
public DelegateCommand TerminalInfoDoubleCommand { get; private set; }
|
||||
public DelegateCommand TerminalInfoIntegerCommand { get; private set; }
|
||||
public DelegateCommand TerminalInfoStringCommand { get; private set; }
|
||||
|
||||
public DelegateCommand CopyRatesCommand { get; private set; }
|
||||
public DelegateCommand CopyTimesCommand { get; private set; }
|
||||
public DelegateCommand CopyOpenCommand { get; private set; }
|
||||
@@ -72,6 +76,7 @@ namespace MtApi5TestClient
|
||||
|
||||
public DelegateCommand ChartOpenCommand { get; private set; }
|
||||
public DelegateCommand ChartApplyTemplateCommand { get; private set; }
|
||||
public DelegateCommand ChartSaveTemplateCommand { get; private set; }
|
||||
|
||||
public DelegateCommand TimeTradeServerCommand { get; private set; }
|
||||
public DelegateCommand TimeLocalCommand { get; private set; }
|
||||
@@ -105,10 +110,9 @@ namespace MtApi5TestClient
|
||||
|
||||
private async void ExecuteChartApplyTemplate(object o)
|
||||
{
|
||||
AddLog("Executed #1");
|
||||
if (string.IsNullOrEmpty(TimeSeriesValues?.SymbolValue)) return;
|
||||
|
||||
AddLog($"Executed #2 s:{TimeSeriesValues?.SymbolValue}");
|
||||
AddLog($"ExecuteChartApplyTemplate #2 s:{TimeSeriesValues?.SymbolValue}");
|
||||
|
||||
|
||||
var result = await Execute(() =>
|
||||
@@ -116,7 +120,7 @@ namespace MtApi5TestClient
|
||||
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 MT5Path = _mtApiClient.TerminalInfoString(ENUM_TERMINAL_INFO_STRING.TERMINAL_DATA_PATH);
|
||||
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Filter = "Template File (*.tpl)|*.tpl|All files (*.*)|*.*";
|
||||
@@ -124,13 +128,40 @@ namespace MtApi5TestClient
|
||||
{
|
||||
var TemplateName = "\\Files\\mt5api_copy.tpl";
|
||||
var TemplateStringContent = File.ReadAllLines(openFileDialog.FileName);
|
||||
var DestPath = $"{MT5Path}\\MQL5{TemplateName}";
|
||||
File.WriteAllLines($"{MT5Path}\\MQL5{TemplateName}", TemplateStringContent);
|
||||
AddLog($"path: {MT5Path}");
|
||||
_mtApiClient.ChartApplyTemplate(ChartId, TemplateName);
|
||||
}
|
||||
return ChartId;
|
||||
});
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
AddLog("ExecuteChartApplyTemplate: result is null");
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog($"ExecuteChartApplyTemplate: success chartid=>{result}");
|
||||
}
|
||||
|
||||
private async void ExecuteChartSaveTemplate(object o)
|
||||
{
|
||||
|
||||
AddLog($"ExecuteSaveApplyTemplate #1");
|
||||
|
||||
|
||||
var result = await Execute(() =>
|
||||
{
|
||||
|
||||
var MT5Path = _mtApiClient.TerminalInfoString(ENUM_TERMINAL_INFO_STRING.TERMINAL_DATA_PATH);
|
||||
int ChartId = 0; // Actual Chart
|
||||
var TemplateName = "\\Files\\exported.tpl";
|
||||
_mtApiClient.ChartSaveTemplate(ChartId, TemplateName);
|
||||
var DestPath = $"{MT5Path}\\MQL5{TemplateName}";
|
||||
AddLog($"Destination: {TemplateName}");
|
||||
return ChartId;
|
||||
});
|
||||
|
||||
if (result == -1)
|
||||
{
|
||||
AddLog("ChartOpen: result is null");
|
||||
@@ -219,6 +250,11 @@ namespace MtApi5TestClient
|
||||
public ENUM_ACCOUNT_INFO_INTEGER AccountInfoIntegerPropertyId { get; set; }
|
||||
public ENUM_ACCOUNT_INFO_STRING AccountInfoStringPropertyId { get; set; }
|
||||
|
||||
public ENUM_TERMINAL_INFO_DOUBLE TerminalInfoDoublePropertyId { get; set; }
|
||||
public ENUM_TERMINAL_INFO_INTEGER TerminalInfoIntegerPropertyId { get; set; }
|
||||
public ENUM_TERMINAL_INFO_STRING TerminalInfoStringPropertyId { get; set; }
|
||||
|
||||
|
||||
public TimeSeriesValueViewModel TimeSeriesValues { get; set; }
|
||||
|
||||
public ObservableCollection<string> TimeSeriesResults { get; } = new ObservableCollection<string>();
|
||||
@@ -297,6 +333,10 @@ namespace MtApi5TestClient
|
||||
AccountInfoIntegerCommand = new DelegateCommand(ExecuteAccountInfoInteger);
|
||||
AccountInfoStringCommand = new DelegateCommand(ExecuteAccountInfoString);
|
||||
|
||||
TerminalInfoDoubleCommand = new DelegateCommand(ExecuteTerminalInfoDouble);
|
||||
TerminalInfoIntegerCommand = new DelegateCommand(ExecuteTerminalInfoInteger);
|
||||
TerminalInfoStringCommand = new DelegateCommand(ExecuteTerminalInfoString);
|
||||
|
||||
CopyRatesCommand = new DelegateCommand(ExecuteCopyRates);
|
||||
CopyTimesCommand = new DelegateCommand(ExecuteCopyTime);
|
||||
CopyOpenCommand = new DelegateCommand(ExecuteCopyOpen);
|
||||
@@ -335,6 +375,7 @@ namespace MtApi5TestClient
|
||||
|
||||
ChartOpenCommand = new DelegateCommand(ExecuteChartOpen);
|
||||
ChartApplyTemplateCommand = new DelegateCommand(ExecuteChartApplyTemplate);
|
||||
ChartSaveTemplateCommand = new DelegateCommand(ExecuteChartSaveTemplate);
|
||||
|
||||
|
||||
TimeCurrentCommand = new DelegateCommand(ExecuteTimeCurrent);
|
||||
@@ -483,7 +524,7 @@ namespace MtApi5TestClient
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.AccountInfoInteger(AccountInfoIntegerPropertyId));
|
||||
|
||||
var message = $"AccountInfoInteger: property_id = {AccountInfoDoublePropertyId}; result = {result}";
|
||||
var message = $"AccountInfoInteger: property_id = {AccountInfoIntegerPropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
@@ -491,10 +532,35 @@ namespace MtApi5TestClient
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.AccountInfoString(AccountInfoStringPropertyId));
|
||||
|
||||
var message = $"AccountInfoString: property_id = {AccountInfoDoublePropertyId}; result = {result}";
|
||||
var message = $"AccountInfoString: property_id = {AccountInfoStringPropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
private async void ExecuteTerminalInfoDouble(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.TerminalInfoDouble(TerminalInfoDoublePropertyId));
|
||||
|
||||
var message = $"TerminalInfoDouble: property_id = {TerminalInfoDoublePropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
private async void ExecuteTerminalInfoInteger(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.TerminalInfoInteger(TerminalInfoIntegerPropertyId));
|
||||
|
||||
var message = $"TerminalInfoInteger: property_id = {TerminalInfoIntegerPropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
private async void ExecuteTerminalInfoString(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.TerminalInfoString(TerminalInfoStringPropertyId));
|
||||
|
||||
var message = $"TerminalInfoString: property_id = {TerminalInfoStringPropertyId}; result = {result}";
|
||||
AddLog(message);
|
||||
}
|
||||
|
||||
|
||||
private async void ExecuteCopyTime(object o)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TimeSeriesValues?.SymbolValue)) return;
|
||||
|
||||
+84
-9
@@ -706,33 +706,43 @@ int executeCommand()
|
||||
Execute_IndicatorRelease();
|
||||
break;
|
||||
|
||||
|
||||
case 241: //ChartOpen
|
||||
Execute_ChartOpen();
|
||||
break;
|
||||
|
||||
case 242: //ChartFirst
|
||||
Execute_ChartFirst();
|
||||
break;
|
||||
|
||||
case 243: //ChartFirst
|
||||
Execute_ChartNext();
|
||||
break;
|
||||
|
||||
case 245: //ChartFirst
|
||||
Execute_ChartSymbol();
|
||||
break;
|
||||
|
||||
case 236: //ChartApplyTemplate
|
||||
Execute_ChartApplyTemplate();
|
||||
break;
|
||||
|
||||
case 252: //ChartGetString
|
||||
Execute_ChartGetString();
|
||||
break;
|
||||
|
||||
case 236: //ChartApplyTemplate
|
||||
Execute_ChartApplyTemplate();
|
||||
break;
|
||||
|
||||
case 237: //ChartApplyTemplate
|
||||
Execute_ChartSaveTemplate();
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 153: //TerminalInfoString
|
||||
Execute_TerminalInfoString();
|
||||
break;
|
||||
case 204: //TerminalInfoInteger
|
||||
Execute_TerminalInfoInteger();
|
||||
break;
|
||||
case 205: //TerminalInfoDouble
|
||||
Execute_TerminalInfoDouble();
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 132: //GetLastError
|
||||
@@ -6151,7 +6161,6 @@ void Execute_ChartApplyTemplate()
|
||||
return;
|
||||
}
|
||||
StringReplace(TemplateFileName, "\\", "\\\\");
|
||||
ResetLastError();
|
||||
|
||||
if (!sendBooleanResponse(ExpertHandle, ChartApplyTemplate(ChartId, TemplateFileName), _response_error))
|
||||
{
|
||||
@@ -6160,6 +6169,35 @@ void Execute_ChartApplyTemplate()
|
||||
ChartRedraw(ChartId);
|
||||
}
|
||||
|
||||
void Execute_ChartSaveTemplate()
|
||||
{
|
||||
long ChartId;
|
||||
string TemplateFileName;
|
||||
StringInit(TemplateFileName, 100, 0);
|
||||
|
||||
|
||||
if (!getLongValue(ExpertHandle, 0, ChartId, _error))
|
||||
{
|
||||
PrintParamError("ChartSaveTemplate", "ChartId", _error);
|
||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||
return;
|
||||
}
|
||||
if (!getStringValue(ExpertHandle, 1, TemplateFileName, _error))
|
||||
{
|
||||
PrintParamError("ChartSaveTemplate", "TemplateFileName", _error);
|
||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||
return;
|
||||
}
|
||||
StringReplace(TemplateFileName, "\\", "\\\\");
|
||||
|
||||
if (!sendBooleanResponse(ExpertHandle, ChartSaveTemplate(ChartId, TemplateFileName), _response_error))
|
||||
{
|
||||
PrintResponseError("ChartSaveTemplate", _response_error);
|
||||
}
|
||||
ChartRedraw(ChartId);
|
||||
}
|
||||
|
||||
|
||||
void Execute_ChartGetString()
|
||||
{
|
||||
long ChartId;
|
||||
@@ -6202,6 +6240,43 @@ void Execute_TerminalInfoString()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Execute_TerminalInfoInteger()
|
||||
{
|
||||
int propertyId;
|
||||
|
||||
if (!getIntValue(ExpertHandle, 0, propertyId, _error))
|
||||
{
|
||||
PrintParamError("TerminalInfoInteger", "propertyId", _error);
|
||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sendIntResponse(ExpertHandle, TerminalInfoInteger((ENUM_TERMINAL_INFO_INTEGER)propertyId), _response_error))
|
||||
{
|
||||
PrintResponseError("TerminalInfoInteger", _response_error);
|
||||
}
|
||||
}
|
||||
|
||||
void Execute_TerminalInfoDouble()
|
||||
{
|
||||
int propertyId;
|
||||
|
||||
if (!getIntValue(ExpertHandle, 0, propertyId, _error))
|
||||
{
|
||||
PrintParamError("TerminalInfoDouble", "propertyId", _error);
|
||||
sendErrorResponse(ExpertHandle, -1, _error, _response_error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sendDoubleResponse(ExpertHandle, TerminalInfoDouble((ENUM_TERMINAL_INFO_DOUBLE)propertyId), _response_error))
|
||||
{
|
||||
PrintResponseError("TerminalInfoDouble", _response_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
string ExecuteRequest_IndicatorCreate(JSONObject *jo)
|
||||
{
|
||||
//Symbol
|
||||
|
||||
Reference in New Issue
Block a user