mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-29 03:27:48 +00:00
Issue #202: [MT5] added Buy/Sell functions
This commit is contained in:
@@ -497,6 +497,7 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<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">
|
||||
@@ -505,6 +506,10 @@
|
||||
<Button Command="{Binding PositionCloseCommand}" Content="PositionClose" Margin="2"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="2" Command="{Binding PositionCloseAllCommand}" Content="PositionCloseAll" Margin="2" HorizontalAlignment="Left"/>
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="4">
|
||||
<Button Command="{Binding BuyCommand}" Content="Buy" Width="60" Margin="2" HorizontalAlignment="Left"/>
|
||||
<Button Command="{Binding SellCommand}" Content="Sell" Width="60" Margin="2" HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ namespace MtApi5TestClient
|
||||
public DelegateCommand PositionOpenCommand { get; private set; }
|
||||
public DelegateCommand PositionCloseCommand { get; private set; }
|
||||
public DelegateCommand PositionCloseAllCommand { get; private set; }
|
||||
public DelegateCommand BuyCommand { get; private set; }
|
||||
public DelegateCommand SellCommand { get; private set; }
|
||||
|
||||
public DelegateCommand GetLastErrorCommand { get; private set; }
|
||||
public DelegateCommand ResetLastErrorCommand { get; private set; }
|
||||
@@ -386,6 +388,8 @@ namespace MtApi5TestClient
|
||||
PositionOpenCommand = new DelegateCommand(ExecutePositionOpen);
|
||||
PositionCloseCommand = new DelegateCommand(ExecutePositionClose);
|
||||
PositionCloseAllCommand = new DelegateCommand(ExecutePositionCloseAll);
|
||||
BuyCommand = new DelegateCommand(ExecuteBuy);
|
||||
SellCommand = new DelegateCommand(ExecuteSell);
|
||||
|
||||
PrintCommand = new DelegateCommand(ExecutePrint);
|
||||
AlertCommand = new DelegateCommand(ExecuteAlert);
|
||||
@@ -1211,6 +1215,26 @@ namespace MtApi5TestClient
|
||||
AddLog($"PositionCloseAll: count = {retVal}");
|
||||
}
|
||||
|
||||
private async void ExecuteBuy(object obj)
|
||||
{
|
||||
const string symbol = "EURUSD";
|
||||
const double volume = 0.1;
|
||||
MqlTradeResult tradeResult = null;
|
||||
|
||||
var retVal = await Execute(() => _mtApiClient.Buy(out tradeResult, volume, symbol));
|
||||
AddLog($"Buy: symbol EURUSD retVal = {retVal}, result = {tradeResult}");
|
||||
}
|
||||
|
||||
private async void ExecuteSell(object obj)
|
||||
{
|
||||
const string symbol = "EURUSD";
|
||||
const double volume = 0.1;
|
||||
MqlTradeResult tradeResult = null;
|
||||
|
||||
var retVal = await Execute(() => _mtApiClient.Sell(out tradeResult, volume, symbol));
|
||||
AddLog($"Sell: symbol EURUSD retVal = {retVal}, result = {tradeResult}");
|
||||
}
|
||||
|
||||
private async void ExecutePrint(object obj)
|
||||
{
|
||||
var message = MessageText;
|
||||
|
||||
Reference in New Issue
Block a user