mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-27 18:47:55 +00:00
Merge branch 'dev'
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using MtClient;
|
||||
using MtApi5.MtProtocol;
|
||||
using MtApi5.MtProtocol.ICustomRequest;
|
||||
using System.Data;
|
||||
|
||||
namespace MtApi5
|
||||
{
|
||||
@@ -188,6 +189,15 @@ namespace MtApi5
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Load symbols
|
||||
///</summary>
|
||||
public List<string>? GetSymbols(bool selected)
|
||||
{
|
||||
Dictionary<string, object> cmdParams = new() { { "Selected", selected } };
|
||||
return SendCommand<List<string>>(ExecutorHandle, Mt5CommandType.GetSymbols, cmdParams);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if the Expert Advisor runs in the testing mode..
|
||||
///</summary>
|
||||
|
||||
@@ -259,6 +259,7 @@ namespace MtApi5.MtProtocol
|
||||
OrderSendAsync = 302,
|
||||
OrderCheck = 303,
|
||||
Buy = 304,
|
||||
Sell = 305
|
||||
Sell = 305,
|
||||
GetSymbols = 306
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,22 +473,34 @@
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Market Info">
|
||||
<WrapPanel VerticalAlignment="Top" Margin="5">
|
||||
<Button Command="{Binding SymbolsTotalCommand}" Content="SymbolsTotal" Margin="2"/>
|
||||
<Button Command="{Binding SymbolNameCommand}" Content="SymbolName" Margin="2"/>
|
||||
<Button Command="{Binding SymbolSelectCommand}" Content="SymbolSelect" Margin="2"/>
|
||||
<Button Command="{Binding SymbolIsSynchronizedCommand}" Content="SymbolIsSynchronized" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoDoubleCommand}" Content="SymbolInfoDouble" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoIntegerCommand}" Content="SymbolInfoInteger" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoStringCommand}" Content="SymbolInfoString" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoString2Command}" Content="SymbolInfoString-2" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoTickCommand}" Content="SymbolInfoTick" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoSessionQuoteCommand}" Content="SymbolInfoSessionQuote" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoSessionTradeCommand}" Content="SymbolInfoSessionTrade" Margin="2"/>
|
||||
<Button Command="{Binding MarketBookAddCommand}" Content="MarketBookAdd" Margin="2"/>
|
||||
<Button Command="{Binding MarketBookReleaseCommand}" Content="MarketBookRelease" Margin="2"/>
|
||||
<Button Command="{Binding MarketBookGetCommand}" Content="MarketBookGet" Margin="2"/>
|
||||
</WrapPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<WrapPanel Grid.Row="0" VerticalAlignment="Top" Margin="5">
|
||||
<Button Command="{Binding SymbolsTotalCommand}" Content="SymbolsTotal" Margin="2"/>
|
||||
<Button Command="{Binding SymbolNameCommand}" Content="SymbolName" Margin="2"/>
|
||||
<Button Command="{Binding SymbolSelectCommand}" Content="SymbolSelect" Margin="2"/>
|
||||
<Button Command="{Binding SymbolIsSynchronizedCommand}" Content="SymbolIsSynchronized" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoDoubleCommand}" Content="SymbolInfoDouble" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoIntegerCommand}" Content="SymbolInfoInteger" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoStringCommand}" Content="SymbolInfoString" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoString2Command}" Content="SymbolInfoString-2" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoTickCommand}" Content="SymbolInfoTick" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoSessionQuoteCommand}" Content="SymbolInfoSessionQuote" Margin="2"/>
|
||||
<Button Command="{Binding SymbolInfoSessionTradeCommand}" Content="SymbolInfoSessionTrade" Margin="2"/>
|
||||
<Button Command="{Binding MarketBookAddCommand}" Content="MarketBookAdd" Margin="2"/>
|
||||
<Button Command="{Binding MarketBookReleaseCommand}" Content="MarketBookRelease" Margin="2"/>
|
||||
<Button Command="{Binding MarketBookGetCommand}" Content="MarketBookGet" Margin="2"/>
|
||||
</WrapPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
<Button Content="GetSymbols" Command="{Binding GetSymbolsCommand}" Width="100" Margin="2"/>
|
||||
<CheckBox Content="Selected" IsChecked="{Binding GetSymbolsSelected}" Margin="5" />
|
||||
</StackPanel>
|
||||
<ListBox Grid.Row="2" ItemsSource="{Binding Symbols}" Height="Auto" Width="200" HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="CTrade (Positions)">
|
||||
|
||||
@@ -160,6 +160,8 @@ namespace MtApi5TestClient
|
||||
public DelegateCommand GlobalVariablesTotalCommand { get; private set; }
|
||||
|
||||
public DelegateCommand UnlockTicksCommand { get; private set; }
|
||||
|
||||
public DelegateCommand GetSymbolsCommand { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -314,6 +316,19 @@ namespace MtApi5TestClient
|
||||
OnPropertyChanged("PositionTicketValue");
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetSymbolsSelected { get; set; } = false;
|
||||
|
||||
private List<string> _symbols;
|
||||
public List<string> Symbols
|
||||
{
|
||||
get { return _symbols; }
|
||||
set
|
||||
{
|
||||
_symbols = value;
|
||||
OnPropertyChanged("Symbols");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
@@ -475,6 +490,8 @@ namespace MtApi5TestClient
|
||||
GlobalVariablesTotalCommand = new DelegateCommand(ExecuteGlobalVariablesTotal);
|
||||
|
||||
UnlockTicksCommand = new DelegateCommand(ExecuteUnlockTicks);
|
||||
|
||||
GetSymbolsCommand = new DelegateCommand(ExecuteGetSymbols);
|
||||
}
|
||||
|
||||
private bool CanExecuteConnect(object o)
|
||||
@@ -1726,6 +1743,19 @@ namespace MtApi5TestClient
|
||||
_mtApiClient.UnlockTicks();
|
||||
}
|
||||
|
||||
private async void ExecuteGetSymbols(object o)
|
||||
{
|
||||
var result = await Execute(() => _mtApiClient.GetSymbols(GetSymbolsSelected));
|
||||
if (result == null)
|
||||
return;
|
||||
|
||||
AddLog($"ChartScreenShot: {result.Count} count of symbols");
|
||||
RunOnUiThread(() =>
|
||||
{
|
||||
Symbols = result;
|
||||
});
|
||||
}
|
||||
|
||||
private static void RunOnUiThread(Action action)
|
||||
{
|
||||
Application.Current?.Dispatcher.Invoke(action);
|
||||
|
||||
Binary file not shown.
+24
-1
@@ -1,7 +1,7 @@
|
||||
#property copyright "Vyacheslav Demidyuk"
|
||||
#property link ""
|
||||
|
||||
#property version "2.0"
|
||||
#property version "2.1"
|
||||
#property description "MtApi (MT5) connection expert"
|
||||
|
||||
#include <json.mqh>
|
||||
@@ -380,6 +380,7 @@ int preinit()
|
||||
ADD_EXECUTOR(303, OrderCheck);
|
||||
ADD_EXECUTOR(304, Buy);
|
||||
ADD_EXECUTOR(305, Sell);
|
||||
ADD_EXECUTOR(306, GetSymbols);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@@ -3450,6 +3451,28 @@ string Execute_Sell()
|
||||
return CreateSuccessResponse(result_value_jo);
|
||||
}
|
||||
|
||||
string Execute_GetSymbols()
|
||||
{
|
||||
GET_JSON_PAYLOAD(jo);
|
||||
GET_BOOL_JSON_VALUE(jo, "Selected", selected);
|
||||
|
||||
const int symbolsCount = SymbolsTotal(selected);
|
||||
JSONArray* jaSymbols = new JSONArray();
|
||||
int idx = 0;
|
||||
for(int idxSymbol = 0; idxSymbol < symbolsCount; idxSymbol++)
|
||||
{
|
||||
string symbol = SymbolName(idxSymbol, selected);
|
||||
string firstChar = StringSubstr(symbol, 0, 1);
|
||||
if(firstChar != "#" && StringLen(symbol) == 6)
|
||||
{
|
||||
jaSymbols.put(idx, new JSONString(symbol));
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
return CreateSuccessResponse(jaSymbols);
|
||||
}
|
||||
|
||||
int PositionCloseAll()
|
||||
{
|
||||
CTrade trade;
|
||||
|
||||
Reference in New Issue
Block a user