Issue #92: Updated test application (MT5) to use functions IndicatorCreate and IndicatorRelease

This commit is contained in:
vdemydiuk
2018-02-27 18:26:37 +02:00
parent f7e06c1570
commit 0086b02bc8
6 changed files with 108 additions and 59 deletions
+55 -25
View File
@@ -84,6 +84,13 @@
<x:Type TypeName="mtapi5:ENUM_TIMEFRAMES"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="ENUM_INDICATOR_Key" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="mtapi5:ENUM_INDICATOR"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
<Grid x:Name="_MainLayout">
@@ -305,32 +312,37 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1">
<Grid Grid.Column="1" Margin="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Symbol Name" Margin="1"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="TimeFrame" Margin="1" HorizontalAlignment="Right"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="StartPos" Margin="1" HorizontalAlignment="Right"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="Count" Margin="1" HorizontalAlignment="Right"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TimeSeriesValues.SymbolValue}" Margin="1"/>
<ComboBox Grid.Row="1" Grid.Column="1" Margin="1"
ItemsSource="{Binding Source={StaticResource ENUM_TIMEFRAMES_Key}}"
SelectedItem="{Binding TimeSeriesValues.TimeFrame}"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding TimeSeriesValues.StartPos}" Margin="1"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding TimeSeriesValues.Count}" Margin="1"/>
</Grid>
<TextBox Grid.Row="0" Text="symbolName"/>
<TextBox Grid.Row="1" Grid.Column="0" Text="timeframe"/>
<TextBox Grid.Row="2" Grid.Column="0" Text="startPos"/>
<TextBox Grid.Row="3" Grid.Column="0" Text="count"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding TimeSeriesValues.SymbolValue}"/>
<ComboBox Grid.Row="1" Grid.Column="1"
ItemsSource="{Binding Source={StaticResource ENUM_TIMEFRAMES_Key}}"
SelectedItem="{Binding TimeSeriesValues.TimeFrame}"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding TimeSeriesValues.StartPos}"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding TimeSeriesValues.Count}"/>
<WrapPanel Grid.Row="4" Grid.ColumnSpan="2" Grid.Column="0" Margin="10">
<WrapPanel Grid.Row="1" Grid.Column="0" Margin="5">
<Button Command="{Binding CopyRatesCommand}" Margin="1"
Content="CopyRates" HorizontalAlignment="Left" />
<Button Command="{Binding CopyTimesCommand}" Margin="1"
@@ -351,15 +363,33 @@
Content="CopySpread" HorizontalAlignment="Left" />
<Button Command="{Binding CopyTicksCommand}" Margin="1"
Content="CopyTicks" HorizontalAlignment="Left" />
<Button Command="{Binding IndicatorCreateCommand}" Margin="1"
Content="IndicatorCreate" HorizontalAlignment="Left" />
<Button Command="{Binding IndicatorReleaseCommand}" Margin="1"
Content="IndicatorRelease" HorizontalAlignment="Left" />
</WrapPanel>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ComboBox Grid.Row="0" Grid.Column="0"
ItemsSource="{Binding Source={StaticResource ENUM_INDICATOR_Key}}"
SelectedItem="{Binding TimeSeriesValues.IndicatorType}"/>
<Button Grid.Row="0" Grid.Column="1" Command="{Binding IndicatorCreateCommand}" Margin="2"
Content="IndicatorCreate" HorizontalAlignment="Left" />
<Label Grid.Row="1" Grid.Column="0" Content="Indicator handle:" Margin="2"/>
<TextBox Grid.Row="1" Grid.Column="0" Margin="2" Width="30" PreviewTextInput="NumberValidationTextBox" Text="{Binding TimeSeriesValues.IndicatorHandle}"></TextBox>
<Button Grid.Row="1" Grid.Column="1" Command="{Binding IndicatorReleaseCommand}" Margin="2"
Content="IndicatorRelease" HorizontalAlignment="Left" />
</Grid>
</Grid>
<ListBox ItemsSource="{Binding TimeSeriesResults}" />
<ListBox Grid.Column="0" ItemsSource="{Binding TimeSeriesResults}" />
</Grid>
</TabItem>
+12 -17
View File
@@ -1,37 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MtApi5TestClient
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow
{
ViewModel _vm { get; set; }
private ViewModel Vm { get; }
public MainWindow()
{
InitializeComponent();
_vm = new ViewModel();
_MainLayout.DataContext = _vm;
Vm = new ViewModel();
_MainLayout.DataContext = Vm;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
_vm.Close();
Vm.Close();
}
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
var regex = new Regex("[^0-9]+");
e.Handled = regex.IsMatch(e.Text);
}
}
}
@@ -1,21 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MtApi5;
using MtApi5;
using System.ComponentModel;
namespace MtApi5TestClient
{
public class TimeSeriesValueViewModel : INotifyPropertyChanged
{
private string _SymbolValue;
private string _symbolValue;
public string SymbolValue
{
get { return _SymbolValue; }
get { return _symbolValue; }
set
{
_SymbolValue = value;
_symbolValue = value;
OnPropertyChanged("SymbolValue");
}
}
@@ -24,13 +20,36 @@ namespace MtApi5TestClient
public int StartPos { get; set; }
public int Count { get; set; }
private int _indicatorHandle;
public int IndicatorHandle
{
get { return _indicatorHandle; }
set
{
_indicatorHandle = value;
OnPropertyChanged("IndicatorHandle");
}
}
private ENUM_INDICATOR _indicatorType = ENUM_INDICATOR.IND_MACD;
public ENUM_INDICATOR IndicatorType
{
get { return _indicatorType; }
set
{
_indicatorType = value;
OnPropertyChanged("IndicatorType");
}
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
var handler = PropertyChanged;
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
+11 -6
View File
@@ -7,7 +7,6 @@ using MtApi5;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Threading.Tasks;
using System.Windows.Documents;
namespace MtApi5TestClient
{
@@ -568,12 +567,17 @@ namespace MtApi5TestClient
new MqlParam
{
DataType = ENUM_DATATYPE.TYPE_INT,
IntegerValue = 0
IntegerValue = 12
},
new MqlParam
{
DataType = ENUM_DATATYPE.TYPE_INT,
IntegerValue = 21
IntegerValue = 26
},
new MqlParam
{
DataType = ENUM_DATATYPE.TYPE_INT,
IntegerValue = 9
},
new MqlParam
{
@@ -584,17 +588,18 @@ namespace MtApi5TestClient
const string symbol = "EURUSD";
const ENUM_TIMEFRAMES timeframe = ENUM_TIMEFRAMES.PERIOD_H1;
const ENUM_INDICATOR indicatorType = ENUM_INDICATOR.IND_MA;
const ENUM_INDICATOR indicatorType = ENUM_INDICATOR.IND_MACD;
var retVal = await Execute(() => _mtApiClient.IndicatorCreate(symbol, timeframe, indicatorType, parameters));
TimeSeriesValues.IndicatorHandle = retVal;
AddLog($"IndicatorCreate [IND_MA]: result - {retVal}");
}
private async void ExecuteIndicatorRelease(object o)
{
const int indicatorHandle = 111;
var indicatorHandle = TimeSeriesValues.IndicatorHandle;
var retVal = await Execute(() => _mtApiClient.IndicatorRelease(indicatorHandle));
AddLog($"IndicatorRelease: result - {retVal}");
AddLog($"IndicatorRelease [{indicatorHandle}]: result - {retVal}");
}
private async void ExecuteCopyRates(object o)
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -39,7 +39,7 @@
bool getBooleanValue(int expertHandle, int paramIndex, bool& res, string& err);
#import
#define __DEBUG_LOG__
//#define __DEBUG_LOG__
input int Port = 8228;