Issue #143: Added function TesterStop [MT5]

This commit is contained in:
vdemydiuk
2019-05-04 10:36:46 +03:00
parent 5f4ae3cd9e
commit ee81cfe012
6 changed files with 40 additions and 1 deletions
+2 -1
View File
@@ -251,6 +251,7 @@ namespace MtApi5
GlobalVariablesTotal = 158, GlobalVariablesTotal = 158,
UnlockTicks = 159, UnlockTicks = 159,
PositionCloseAll = 160 PositionCloseAll = 160,
TesterStop = 161
} }
} }
+8
View File
@@ -2081,6 +2081,14 @@ namespace MtApi5
SendCommand<object>(Mt5CommandType.Alert, commandParameters); SendCommand<object>(Mt5CommandType.Alert, commandParameters);
} }
///<summary>
///Gives program operation completion command when testing.
///</summary>
public void TesterStop()
{
SendCommand<object>(Mt5CommandType.TesterStop, null);
}
#endregion // Common Functions #endregion // Common Functions
#region Object Functions #region Object Functions
@@ -582,6 +582,7 @@
<WrapPanel VerticalAlignment="Top" Margin="5"> <WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding GetLastErrorCommand}" Content="GetLastError" Margin="2"/> <Button Command="{Binding GetLastErrorCommand}" Content="GetLastError" Margin="2"/>
<Button Command="{Binding ResetLastErrorCommand}" Content="ResetLastError" Margin="2"/> <Button Command="{Binding ResetLastErrorCommand}" Content="ResetLastError" Margin="2"/>
<Button Command="{Binding TesterStopCommand}" Content="TesterStop" Margin="2"/>
</WrapPanel> </WrapPanel>
<Button Grid.Row="1" Content="UnlockTicks" HorizontalAlignment="Left" Margin="5" Command="{Binding UnlockTicksCommand}"/> <Button Grid.Row="1" Content="UnlockTicks" HorizontalAlignment="Left" Margin="5" Command="{Binding UnlockTicksCommand}"/>
@@ -73,6 +73,7 @@ namespace MtApi5TestClient
public DelegateCommand ResetLastErrorCommand { get; private set; } public DelegateCommand ResetLastErrorCommand { get; private set; }
public DelegateCommand PrintCommand { get; private set; } public DelegateCommand PrintCommand { get; private set; }
public DelegateCommand AlertCommand { get; private set; } public DelegateCommand AlertCommand { get; private set; }
public DelegateCommand TesterStopCommand { get; private set; }
public DelegateCommand iCustomCommand { get; private set; } public DelegateCommand iCustomCommand { get; private set; }
@@ -382,6 +383,7 @@ namespace MtApi5TestClient
AlertCommand = new DelegateCommand(ExecuteAlert); AlertCommand = new DelegateCommand(ExecuteAlert);
GetLastErrorCommand = new DelegateCommand(ExecuteGetLastError); GetLastErrorCommand = new DelegateCommand(ExecuteGetLastError);
ResetLastErrorCommand = new DelegateCommand(ExecuteResetLastError); ResetLastErrorCommand = new DelegateCommand(ExecuteResetLastError);
TesterStopCommand = new DelegateCommand(ExecuteTesterStop);
iCustomCommand = new DelegateCommand(ExecuteICustom); iCustomCommand = new DelegateCommand(ExecuteICustom);
@@ -1169,6 +1171,12 @@ namespace MtApi5TestClient
AddLog("ResetLastError: executed."); AddLog("ResetLastError: executed.");
} }
private void ExecuteTesterStop(object obj)
{
_mtApiClient.TesterStop();
AddLog("TesterStop: executed.");
}
private async void ExecuteICustom(object o) private async void ExecuteICustom(object o)
{ {
const string symbol = "EURUSD"; const string symbol = "EURUSD";
BIN
View File
Binary file not shown.
+21
View File
@@ -791,6 +791,9 @@ int executeCommand()
case 160: //PositionCloseAll case 160: //PositionCloseAll
Execute_PositionCloseAll(); Execute_PositionCloseAll();
break; break;
case 161: //TesterStop
Execute_TesterStop();
break;
case 204: //TerminalInfoInteger case 204: //TerminalInfoInteger
Execute_TerminalInfoInteger(); Execute_TerminalInfoInteger();
break; break;
@@ -6507,6 +6510,24 @@ void Execute_PositionCloseAll()
SEND_INT_RESPONSE(res) SEND_INT_RESPONSE(res)
} }
void Execute_TesterStop()
{
if (!IsTesting())
{
Print("WARNING: function UnlockTicks can be used only for backtesting");
}
else
{
Print("TesterStop called.");
TesterStop();
}
if (!sendVoidResponse(ExpertHandle, _response_error))
{
PrintResponseError("TesterStop", _response_error);
}
}
void Execute_TerminalInfoInteger() void Execute_TerminalInfoInteger()
{ {
int propertyId; int propertyId;