mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-27 18:47:55 +00:00
Chart Commands:
- ChartSaveTemplate Implemented
This commit is contained in:
@@ -479,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">
|
||||
|
||||
@@ -76,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; }
|
||||
@@ -129,12 +130,38 @@ namespace MtApi5TestClient
|
||||
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");
|
||||
@@ -348,6 +375,7 @@ namespace MtApi5TestClient
|
||||
|
||||
ChartOpenCommand = new DelegateCommand(ExecuteChartOpen);
|
||||
ChartApplyTemplateCommand = new DelegateCommand(ExecuteChartApplyTemplate);
|
||||
ChartSaveTemplateCommand = new DelegateCommand(ExecuteChartSaveTemplate);
|
||||
|
||||
|
||||
TimeCurrentCommand = new DelegateCommand(ExecuteTimeCurrent);
|
||||
|
||||
+38
-4
@@ -719,13 +719,19 @@ int executeCommand()
|
||||
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();
|
||||
@@ -6155,7 +6161,6 @@ void Execute_ChartApplyTemplate()
|
||||
return;
|
||||
}
|
||||
StringReplace(TemplateFileName, "\\", "\\\\");
|
||||
ResetLastError();
|
||||
|
||||
if (!sendBooleanResponse(ExpertHandle, ChartApplyTemplate(ChartId, TemplateFileName), _response_error))
|
||||
{
|
||||
@@ -6164,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;
|
||||
|
||||
Reference in New Issue
Block a user