Issue #119: Added out parameter MqlTradeResult to function PositionClose

This commit is contained in:
vdemydiuk
2018-06-04 17:48:14 +03:00
parent 5d78ad5067
commit 0f717f1cb7
9 changed files with 144 additions and 12 deletions
+13 -4
View File
@@ -481,10 +481,19 @@
</WrapPanel>
</TabItem>
<TabItem Header="CTrade">
<WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding PositionOpenCommand}" Content="PositionOpen" Margin="2"/>
</WrapPanel>
<TabItem Header="CTrade (Positions)">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Command="{Binding PositionOpenCommand}" Content="PositionOpen" Margin="2" HorizontalAlignment="Left"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="4">
<TextBlock Text="Ticket:" VerticalAlignment="Center"/>
<TextBox Text="{Binding PositionTicketValue}" Width="150" Margin="2"/>
<Button Command="{Binding PositionCloseCommand}" Content="PositionClose" Margin="2"/>
</StackPanel>
</Grid>
</TabItem>
<TabItem Header="Indicators">
+22
View File
@@ -66,6 +66,7 @@ namespace MtApi5TestClient
public DelegateCommand MarketBookGetCommand { get; private set; }
public DelegateCommand PositionOpenCommand { get; private set; }
public DelegateCommand PositionCloseCommand { get; private set; }
public DelegateCommand GetLastErrorCommand { get; private set; }
public DelegateCommand ResetLastErrorCommand { get; private set; }
@@ -263,6 +264,17 @@ namespace MtApi5TestClient
OnPropertyChanged("GlobalVarValue");
}
}
private ulong _positionTicketValue;
public ulong PositionTicketValue
{
get { return _positionTicketValue; }
set
{
_positionTicketValue = value;
OnPropertyChanged("PositionTicketValue");
}
}
#endregion
#region Public Methods
@@ -358,6 +370,7 @@ namespace MtApi5TestClient
MarketBookGetCommand = new DelegateCommand(ExecuteMarketBookGet);
PositionOpenCommand = new DelegateCommand(ExecutePositionOpen);
PositionCloseCommand = new DelegateCommand(ExecutePositionClose);
PrintCommand = new DelegateCommand(ExecutePrint);
AlertCommand = new DelegateCommand(ExecuteAlert);
@@ -1098,6 +1111,15 @@ namespace MtApi5TestClient
AddLog($"PositionOpen: symbol EURUSD retVal = {retVal}, result = {tradeResult}");
}
private async void ExecutePositionClose(object obj)
{
var ticket = PositionTicketValue;
MqlTradeResult tradeResult = null;
var retVal = await Execute(() => _mtApiClient.PositionClose(ticket, out tradeResult));
AddLog($"PositionClose: ticket {ticket} retVal = {retVal}, result = {tradeResult}");
}
private async void ExecutePrint(object obj)
{
var message = MessageText;