mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-15 11:48:09 +00:00
Chart Commands:
- ChartSaveTemplate Implemented
This commit is contained in:
@@ -479,10 +479,11 @@
|
|||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Chart Functions">
|
<TabItem Header="Chart Functions">
|
||||||
<WrapPanel>
|
<WrapPanel VerticalAlignment="Top" Margin="5">
|
||||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TimeSeriesValues.SymbolValue}" Margin="1"/>
|
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TimeSeriesValues.SymbolValue}" Margin="1"/>
|
||||||
<Button Command="{Binding ChartOpenCommand}" Content="ChartOpen"/>
|
<Button Command="{Binding ChartOpenCommand}" Content="ChartOpen"/>
|
||||||
<Button Command="{Binding ChartApplyTemplateCommand}" Content="ChartApplyTemplate"/>
|
<Button Command="{Binding ChartApplyTemplateCommand}" Content="ChartApplyTemplate"/>
|
||||||
|
<Button Command="{Binding ChartSaveTemplateCommand}" Content="ChartSaveTemplate"/>
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Time and Date">
|
<TabItem Header="Time and Date">
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ namespace MtApi5TestClient
|
|||||||
|
|
||||||
public DelegateCommand ChartOpenCommand { get; private set; }
|
public DelegateCommand ChartOpenCommand { get; private set; }
|
||||||
public DelegateCommand ChartApplyTemplateCommand { get; private set; }
|
public DelegateCommand ChartApplyTemplateCommand { get; private set; }
|
||||||
|
public DelegateCommand ChartSaveTemplateCommand { get; private set; }
|
||||||
|
|
||||||
public DelegateCommand TimeTradeServerCommand { get; private set; }
|
public DelegateCommand TimeTradeServerCommand { get; private set; }
|
||||||
public DelegateCommand TimeLocalCommand { get; private set; }
|
public DelegateCommand TimeLocalCommand { get; private set; }
|
||||||
@@ -129,12 +130,38 @@ namespace MtApi5TestClient
|
|||||||
var TemplateStringContent = File.ReadAllLines(openFileDialog.FileName);
|
var TemplateStringContent = File.ReadAllLines(openFileDialog.FileName);
|
||||||
var DestPath = $"{MT5Path}\\MQL5{TemplateName}";
|
var DestPath = $"{MT5Path}\\MQL5{TemplateName}";
|
||||||
File.WriteAllLines($"{MT5Path}\\MQL5{TemplateName}", TemplateStringContent);
|
File.WriteAllLines($"{MT5Path}\\MQL5{TemplateName}", TemplateStringContent);
|
||||||
AddLog($"path: {MT5Path}");
|
|
||||||
_mtApiClient.ChartApplyTemplate(ChartId, TemplateName);
|
_mtApiClient.ChartApplyTemplate(ChartId, TemplateName);
|
||||||
}
|
}
|
||||||
return ChartId;
|
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)
|
if (result == -1)
|
||||||
{
|
{
|
||||||
AddLog("ChartOpen: result is null");
|
AddLog("ChartOpen: result is null");
|
||||||
@@ -348,6 +375,7 @@ namespace MtApi5TestClient
|
|||||||
|
|
||||||
ChartOpenCommand = new DelegateCommand(ExecuteChartOpen);
|
ChartOpenCommand = new DelegateCommand(ExecuteChartOpen);
|
||||||
ChartApplyTemplateCommand = new DelegateCommand(ExecuteChartApplyTemplate);
|
ChartApplyTemplateCommand = new DelegateCommand(ExecuteChartApplyTemplate);
|
||||||
|
ChartSaveTemplateCommand = new DelegateCommand(ExecuteChartSaveTemplate);
|
||||||
|
|
||||||
|
|
||||||
TimeCurrentCommand = new DelegateCommand(ExecuteTimeCurrent);
|
TimeCurrentCommand = new DelegateCommand(ExecuteTimeCurrent);
|
||||||
|
|||||||
+38
-4
@@ -719,13 +719,19 @@ int executeCommand()
|
|||||||
case 245: //ChartFirst
|
case 245: //ChartFirst
|
||||||
Execute_ChartSymbol();
|
Execute_ChartSymbol();
|
||||||
break;
|
break;
|
||||||
case 236: //ChartApplyTemplate
|
|
||||||
Execute_ChartApplyTemplate();
|
|
||||||
break;
|
|
||||||
case 252: //ChartGetString
|
case 252: //ChartGetString
|
||||||
Execute_ChartGetString();
|
Execute_ChartGetString();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 236: //ChartApplyTemplate
|
||||||
|
Execute_ChartApplyTemplate();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 237: //ChartApplyTemplate
|
||||||
|
Execute_ChartSaveTemplate();
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 153: //TerminalInfoString
|
case 153: //TerminalInfoString
|
||||||
Execute_TerminalInfoString();
|
Execute_TerminalInfoString();
|
||||||
@@ -6155,7 +6161,6 @@ void Execute_ChartApplyTemplate()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringReplace(TemplateFileName, "\\", "\\\\");
|
StringReplace(TemplateFileName, "\\", "\\\\");
|
||||||
ResetLastError();
|
|
||||||
|
|
||||||
if (!sendBooleanResponse(ExpertHandle, ChartApplyTemplate(ChartId, TemplateFileName), _response_error))
|
if (!sendBooleanResponse(ExpertHandle, ChartApplyTemplate(ChartId, TemplateFileName), _response_error))
|
||||||
{
|
{
|
||||||
@@ -6164,6 +6169,35 @@ void Execute_ChartApplyTemplate()
|
|||||||
ChartRedraw(ChartId);
|
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()
|
void Execute_ChartGetString()
|
||||||
{
|
{
|
||||||
long ChartId;
|
long ChartId;
|
||||||
|
|||||||
Reference in New Issue
Block a user