vdemydiuk / mtapi Goto Github PK
View Code? Open in Web Editor NEWMetaTrader API (terminal bridge)
Home Page: http://mtapi4.net/
License: MIT License
MetaTrader API (terminal bridge)
Home Page: http://mtapi4.net/
License: MIT License
Hello,
Thanks for your api everything is working. But I have a problem;
If I download MtApi_Setup.exe and install it, MTConnector.dll size 494 KB ( Working )
If I built MTConnector project, MTConnector.dll size 485 KB and notworking (MetaTerminal MtApi.ex4 not load file there is no smiling face in the upper right corner)
Thanks.
Hello, I have tried to compile the MTApi.mq4 in the MetaEditor as far as it works but If run this version and in TestApiClinet and click on symbolTotal the ea crached ..
2017.02.15 15:55:31.261 Access violation read to 0x0BFFFFF8 in xxx/Terminal\9099EE68906C5004CBE96894295C3478\MQL4\Experts\MtApi.ex4'
When I started my application I got
log4net:ERROR RollingFileAppender: INTERNAL ERROR. Append is False but OutputFile [C:\Users\Alexey\AppData\Local\Temp\MtApi5Client\Logs\2016-04-11--23-46-42.txt] already exists.
I am not sure what is reason, but looks like there is a initialization of logging from MtApi5.dll itself. I think it is not good way to initialize logging from library and it should be initialized from client application (for instance add appropriate API call) and library itself should only add messages logging calls (they will find log instance correctly).
I am using such configuration in my client (looks like same logging framework is used):
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Trace()
.CreateLogger();
HEllo
in metatrader when i run MtApi it works successfully but i could not connect to localhost 8222 from TestApiClientUI. i am trying to connect over telnet but it also fails
in MetaTrader Experts Log;
2017.03.06 22:15:48.632 MtApi GBPJPY,H1 inputs: Port=8222; 2017.03.06 22:15:47.320 Expert MtApi GBPJPY
,H1: loaded successfully
I could not find support for SymbolInfoDouble. Are there plans to develop? Can I develop and make pull request?
Hello
Is there any sample code for MetaTrader API in asp.net/MVC, I would appreciate if some one can send me any code, I am new to both MetaTrader API and asp.net/mvc.
Thanks in anticipation
Hi,
the WIX installator is missing MTConnector.dll, so whole release is broken. Version before has same fault.
From Amir Aghashahi:
iCustom function not working .. before and after change(because Backstep cannot be greater or equal to Depth) param value in your example for Zigzag .. I use it in other code with RSI .. iCustom donot reply value .. only reply Zero in all time in all my test
An exception is thrown when trying to call an apiclient function from the QuoteUpdated event when backtesting in MT4:
An exception of type 'MtApi.MtConnectionException' occurred in MtApi.dll but was not handled in user code
Additional information: Service connection failed! This operation would deadlock because the reply cannot be received until the current Message completes processing. If you want to allow out-of-order message processing, specify ConcurrencyMode of Reentrant or Multiple on CallbackBehaviorAttribute.
The code below for a test console app fails on call to iBars
for instance:
using MtApi;
using System;
namespace MT4ClientConsole
{
class Program
{
static void Main(string[] args)
{
MtApiClient client = new MtApiClient();
client.QuoteUpdated += Client_QuoteUpdated;
client.BeginConnect("127.0.0.1", 8222);
Console.ReadKey();
}
private static void Client_QuoteUpdated(object sender, string symbol, double bid, double ask)
{
var bars = ((MtApiClient)sender).iBars(symbol, ChartPeriod.PERIOD_M5);
Console.WriteLine("Bars: " + bars);
}
}
}
It is uint instead of ulong
Hello, I'm getting error in reading the IsConnected () method. However the quotes data is being received. I'm using a thread to execute a particular method and I noticed that before the call is made in this method the _apiCliente.IsConnected () statement is set to true. But when I enter the private method it is false. :(
Visual Studio error:
Exception thrown: 'MtApi.MtConnectionException' in MtApi.dll
Additional information: Client is not connected.
Is it possible to send message to the Experts tab of Tools window of MT?
Version 1.0.25 has bug in function GetOrders. It returns orders only from trading pool.
Expected behavior: GetOrders returns orders from trading pool and history pool by input parameter.
(Thanks John Fitton to find this issue).
MQL uses different color representation than C# System.Drawing.Color.
MQL4 color ( https://docs.mql4.com/basis/types/integer/color ):
0x00BBGGRR
00: ignored values
BB: Blue component
GG: Green component
RR: Red component
System.Drawing.Color ( https://msdn.microsoft.com/en-us/library/system.drawing.color%28v=vs.110%29.aspx ):
0xAARRGGBB
AA: Alpha component
BB: Blue component
GG: Green component
RR: Red component
A possible fix in MtApiColorConverter.cs
:
using System.Drawing;
namespace MtApi
{
class MtApiColorConverter
{
public static Color ConvertFromMtColor(int mqlColor)
{
return Color.FromArgb((byte)(mqlColor), (byte)(mqlColor >> 8), (byte)(mqlColor >> 16));
}
public static int ConvertToMtColor(Color color)
{
return color == Color.Empty ? 0xffffff : (Color.FromArgb(color.B, color.G, color.R).ToArgb() & 0xffffff);
}
}
}
В MQL есть методы SymbolsTotal(), SymbolName() и SymbolSelect(). Было бы здорово получить доступ к ним через MtApi4.
I've got an error on backtesting on MT4:
{"After parsing a value an unexpected character was encountered: ". Path 'Orders[0]', line 1, position 201."}
Stack Trace:
...
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at MtApi.MtApiClient.SendRequest[T](RequestBase request) in C:\Users\Serg\Source\Repos\mtapi\MtApi\MtApiClient.cs:line 2365
at MtApi.MtApiClient.GetOrders(OrderSelectSource pool) in C:\Users\Serg\Source\Repos\mtapi\MtApi\MtApiClient.cs:line 505
at MtApi.Monitors.TradeMonitor.CheckOrders() in C:\Users\Serg\Source\Repos\mtapi\MtApi\Monitors\TradeMonitor.cs:line 102
at MtApi.Monitors.TradeMonitor.Check() in C:\Users\Serg\Source\Repos\mtapi\MtApi\Monitors\TradeMonitor.cs:line 82
at MtApi.Monitors.TimeframeTradeMonitor.ApiClient_OnLastTimeBar(Object sender, TimeBarArgs e) in C:\Users\Serg\Source\Repos\mtapi\MtApi\Monitors\TimeframeTradeMonitor.cs:line 51
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at MtApi.MtApiClient.FireOnLastTimeBar(MtTimeBar timeBar) in C:\Users\Serg\Source\Repos\mtapi\MtApi\MtApiClient.cs:line 2421
at MtApi.MtApiClient._client_MtEventReceived(MtEvent e) in C:\Users\Serg\Source\Repos\mtapi\MtApi\MtApiClient.cs:line 2411
at MTApiService.MtClient.OnMtEvent(MtEvent e) in C:\Users\Serg\Source\Repos\mtapi\MTApiService\MtClient.cs:line 250
at SyncInvokeOnMtEvent(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
Parsing string:
{"Orders" : [{"MagicNumber" : 262,"MtCloseTime" : 0,"Commission" : "0","Symbol" : "EURUSD","StopLoss" : 1.116,"OpenPrice" : 1.11934,"MtOpenTime" : 1475608025,"Comment" : "","Magic":262,"RequestType":3},"Ticket" : 1,"Lots" : 1,"ClosePrice" : 1.1192,"Profit" : -14,"TakeProfit" : 1.12747,"Swap" : 0,"MtExpiration" : 0,"Operation" : 0}],"ErrorCode" : 0}
Functions GetOrder (and GetOrders) returns object order with empty symbol.
This problem has been occurred in version 1.0.27 after refactoring mql part.
Hi!
The type of volume (lot size) in MtApi.mq4 (line: 3537) could be double:
double volume = jo.getDouble("Volume");
for more accurate position sizes.
Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Hello,
The OrderStopLoss() and OrderTakeProfit() methods are deprecated, but there are no StopLoss and TakeProfit properties in MtOrder.
Hi. This is not really a bug, but more of a feature request.
I came over a little quirk when it comes to debugging the EA in Visual Studio. I found that the timeout between MT4 server and .NET client is the .NET default (60 seconds).
Is it possible to make the timeout configurable for debugging purposes?
Is it possible to have MtApi
work with multiple symbols without having to drop the EA on each individual chart?
Планируется ли поддержка индикаторов?
Стабильно появляется такая ошибка.
Воспроизводится это как API перестаёт работать - выдаёт результат OK, но нулевые данные (что само по себе плохо, тут не видно что API поломался).
Далее, при закрытии MT5, появляется окошко MtApi с сообщением из сабжа.
После перезапуска MT, API начинает работать некоторое время и далее по кругу.
MtApi5 не работает (не переходит вMt5ConnectionState.Connected после BeginConnect) если объект откуда я вызываю Connect и задаю ConnectionStateChanged унаследован от ReactiveObject (фреймворк reactiveui).
В логе при этом следующее сообщение:
2016-11-18 22:56:18,337 [1] ERROR MTApiService.MtService - ExecuteCallbackAction: Exception - Коммуникационный объект System.ServiceModel.Channels.ServiceChannel нельзя использовать для связи, так как его работа прервана.
2016-11-18 22:56:18,337 [1] WARN MTApiService.MtService - ExecuteCallbackAction: crashed callback count = 1
Priority: Low (I can avoid using ReactiveObject inheritance for a while)
Is it possible to add sync bool Connect function to MtApi5?
Priority is Lowest as soon we always can use AsyncConnect, but sync may be useful sometimes.
The behavior may be following: waiting 5 s, if no connection, then return false.
As advanced feature here may be if no connection, additional checking that MT5 is running, if no, start it in minimized mode and retry connection.
hi guys.
i cant draw any object on charts with Api.
Arrows, Lines, Fibos, HorizantalLines, Trends, VerticalLines, Image, ....
is there any method to do that ?
thanks.
My Metatrader 5 Build 1545 on Windows 10 crashed on call bool initExpert(int expertHandle, int port, string symbol, double bid, double ask, string& err); in MTApi EA.
Logfile:
MP 0 01:07:29.612 Experts automated trading is enabled
HL 2 01:07:35.927 MtApi5 (AUDCAD,H1) Unhandled exception 0xE0434352
DH 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137720 4881ECD8000000 sub rsp, 0xd8
EI 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137727 488B0562781D00 mov rax, [rip+0x1d7862]
EK 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD913772E 4833C4 xor rax, rsp
LK 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137731 48898424C0000000 mov [rsp+0xc0], rax
MR 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137739 488364242800 and qword [rsp+0x28], 0x0
DN 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD913773F 488D05DAFFFFFF lea rax, [rip-0x26]
NM 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137746 83E201 and edx, 0x1
IL 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137749 894C2420 mov [rsp+0x20], ecx
IN 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD913774D 89542424 mov [rsp+0x24], edx
LF 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137751 4889442430 mov [rsp+0x30], rax
FF 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137756 4D85C9 test r9, r9
DH 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137759 7445 jz 0x7ffad91377a0
CJ 2 01:07:35.968 MtApi5 (AUDCAD,H1)
QH 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD913775B B80F000000 mov eax, 0xf
NK 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137760 488D4C2440 lea rcx, [rsp+0x40]
CJ 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137765 443BC0 cmp r8d, eax
QS 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137768 498BD1 mov rdx, r9
DN 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD913776B 440F47C0 cmova r8d, eax
GS 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD913776F 4489442438 mov [rsp+0x38], r8d
PK 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137774 49C1E003 shl r8, 0x3
QD 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137778 E807550600 call 0x7ffad919cc84 ; SHExpandEnvironmentStringsA (kernelbase.dll)
CN 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD913777D 488D4C2420 lea rcx, [rsp+0x20]
CD 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137782 FF15D0081300 call qword near [rip+0x1308d0] ; TerminateProcessOnMemoryExhaustion (kernelbase.dll)
IR 2 01:07:35.968 MtApi5 (AUDCAD,H1) crash --> 00007FFAD9137788 488B8C24C0000000 mov rcx, [rsp+0xc0]
PL 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137790 4833CC xor rcx, rsp
KS 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137793 E8981A0600 call 0x7ffad9199230 ; GetSystemWow64DirectoryW (kernelbase.dll)
OL 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD9137798 4881C4D8000000 add rsp, 0xd8
RO 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD913779F C3 ret
CD 2 01:07:35.968 MtApi5 (AUDCAD,H1)
CP 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD91377A0 8364243800 and dword [rsp+0x38], 0x0
NL 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00007FFAD91377A5 EBD6 jmp 0x7ffad913777d
CR 2 01:07:35.968 MtApi5 (AUDCAD,H1)
IO 2 01:07:35.968 MtApi5 (AUDCAD,H1)
RE 2 01:07:35.968 MtApi5 (AUDCAD,H1) 00: 0x00007FFAD9137788
MN 2 01:07:35.968 MtApi5 (AUDCAD,H1) 01: 0x00000001E06D7363
CF 2 01:07:35.968 MtApi5 (AUDCAD,H1) 02: 0x0000004B365DAE60
IP 2 01:07:35.968 MtApi5 (AUDCAD,H1) 03: 0x0000004B365DB490
HH 2 01:07:35.968 MtApi5 (AUDCAD,H1) 04: 0x0000004B365D9C70
EP 2 01:07:35.968 MtApi5 (AUDCAD,H1) 05: 0x00000001E0434352
KM 2 01:07:35.968 MtApi5 (AUDCAD,H1)
Is this a bug? Or I have created the mt5connector.dll incorrectly. I am using VS15
Memory usage of MetaTrader 4 grows rapidly when using MtApi.
To reproduce start a backtest in MT4 with the strategy tester (one day is enough), run app below (which does nothing but connect), watch the memory usage of the MetaTrader process in the task manager quickly grow to several GB's.
using MtApi;
using System;
namespace MT4ClientConsole
{
class Program
{
static void Main(string[] args)
{
MtApiClient client = new MtApiClient();
client.BeginConnect("127.0.0.1", 8222);
Console.ReadKey();
}
}
}
This functions are necessary:
https://www.mql5.com/ru/docs/objects
Hello,
Can you provide a readme file for your code? I am not be able to build it with VS2013. Maybe, you can list some dependencies. Thanks in advance.
Installed MtApi to MT4's "MQL4\experts" folder, and MTConnector.dll to "MQL4\Libraries" folder, and added that to user's environment PATH.
When dropping MtApi on a chart getting this:
2016.09.30 00:29:12.208 Expert MtApi NZDCAD,H1: removed
2016.09.30 00:29:12.207 MtApi NZDCAD,H1: uninit reason 8
2016.09.30 00:29:12.207 MtApi NZDCAD,H1: not initialized
2016.09.30 00:29:12.207 Unhandled exception 0xE0434352
2016.09.30 00:29:12.169 MtApi NZDCAD,H1 inputs: Port=8222;
Any help on how to troubleshoot it? Does it fail to find the MTConnector.dll? If so, what should be its location?
In 1.0.33 version MT5Connector.cpp needs MtServerInstance replacing with MtAdapter
Hi,
It is a way to use indicators in Backtesting mode, i have always a exception if i try to use it.
I have also a problem with OrderSend in Backtesting mode, i get always a exception with a concurency mode error.
Thanks in advance
Regards
At least in MtApi5 it is bad defined.
Puropose: for deserialization.
I can prepare pull request if needed.
Hi,
after compilation in VS2015, EA load in MT4 and after that crash on error.
2017.03.01 21:01:05.788 MtApi USDCHF,H1: [ERROR] SendLastTimeBartEvent: Nelze naèíst soubor nebo sestavení MTApiService, Version=1.0.25.0, Culture=neutral, PublicKeyToken=fe39c8c11cabcd1e nebo jeden z jejich závislých prvkù. Systém nemùže nalézt uvedený soubor.
2017.03.01 21:01:05.788 MtApi USDCHF,H1: start() new bar: _lastBarOpenTime = 0; Time[0] = 1488405600
2017.03.01 21:01:05.788 MtApi USDCHF,H1: initialized
2017.03.01 21:00:36.823 MtApi USDCHF,H1 inputs: Port=8222;
2017.03.01 21:00:35.338 Expert MtApi USDCHF,H1: loaded successfully
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.