Discussion of article "DIY multi-threaded asynchronous MQL5 WebRequest" - page 4

 
Mohammad Hossein Sadeghi:
Nice article, thanks. How about WinINet Asynchronous mode?

I don't have plans to implement such a thing, sorry.

 

In the Russian discussion of the article one may find further investigation of the approach and an alternative implementation based on chart objects.

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Обсуждение статьи "Многопоточный асинхронный WebRequest на MQL5 своими руками"

Stanislav Korotky, 2018.11.14 14:20

I post an alternative way to launch web requests - with the help of graph objects, which use a template with an expert assistant. It can be used from both experts and indicators. Dependencies are the same as in the article. The files of the new implementation:

  • multiwebobjectworker.mqh - header file with common classes;
  • multiwebobjectworker.mq5 is a working expert performing web requests inside graph objects;
  • multiwebindicator.mq5 - unbuffered indicator showing the launch of web requests;

An object is created for each request, an expert assistant is created in it, and at the end of the request, the object is deleted. The exchange of query data and results, as in the article, is done through resources.

Judging by the logs, this mechanism does not provide full-fledged query execution parallelism, since the objects probably share a common event queue. Example log:

2018.11.14 15:11:58.492 multiwebindicator (EURUSD,H1)   129912254742671348: Starting chart object WRS1 129912254742671349
2018.11.14 15:11:58.694 multiwebindicator (EURUSD,H1)   129912254742671348: Starting chart object WRS2 129912254742671350
2018.11.14 15:11:58.819 multiwebindicator (EURUSD,H1)   129912254742671348: Starting chart object WRS3 129912254742671351
2018.11.14 15:11:58.960 multiwebobjectworker (EURUSD,H1)        129912254742671349: OnInit
2018.11.14 15:11:58.960 multiwebobjectworker (EURUSD,H1)        129912254742671349: Reading request \Indicators\multiwebindicator.ex5::WRS_0_129912254742671348
2018.11.14 15:11:58.960 multiwebobjectworker (EURUSD,H1)        129912254742671349: Got 64 bytes in request
2018.11.14 15:11:58.960 multiwebobjectworker (EURUSD,H1)        129912254742671349: GET https://google.com/ User-Agent: n/a 5000 
2018.11.14 15:11:58.975 multiwebobjectworker (EURUSD,H1)        129912254742671350: OnInit
2018.11.14 15:11:58.975 multiwebobjectworker (EURUSD,H1)        129912254742671350: Reading request \Indicators\multiwebindicator.ex5::WRS_1_129912254742671348
2018.11.14 15:11:58.975 multiwebobjectworker (EURUSD,H1)        129912254742671350: Got 60 bytes in request
2018.11.14 15:11:58.975 multiwebobjectworker (EURUSD,H1)        129912254742671350: GET https://ya.ru User-Agent: n/a 5000 
2018.11.14 15:11:59.084 multiwebobjectworker (EURUSD,H1)        129912254742671351: OnInit
2018.11.14 15:11:59.084 multiwebobjectworker (EURUSD,H1)        129912254742671351: Reading request \Indicators\multiwebindicator.ex5::WRS_2_129912254742671348
2018.11.14 15:11:59.084 multiwebobjectworker (EURUSD,H1)        129912254742671351: Got 72 bytes in request
2018.11.14 15:11:59.084 multiwebobjectworker (EURUSD,H1)        129912254742671351: GET https://www.startpage.com/ User-Agent: n/a 5000 
2018.11.14 15:11:59.162 multiwebobjectworker (EURUSD,H1)        129912254742671350: Done in 187ms
2018.11.14 15:11:59.178 multiwebindicator (EURUSD,H1)   129912254742671348: Result code 200
2018.11.14 15:11:59.178 multiwebindicator (EURUSD,H1)   129912254742671348: Reading result \Experts\multiwebobjectworker.ex5::WRS_0_129912254742671350
2018.11.14 15:11:59.178 multiwebindicator (EURUSD,H1)   129912254742671348: Got 16592 bytes in response
2018.11.14 15:11:59.178 multiwebindicator (EURUSD,H1)   GET https://ya.ru
2018.11.14 15:11:59.178 multiwebindicator (EURUSD,H1)   Received 3734 bytes in header, 12775 bytes in document
2018.11.14 15:11:59.256 multiwebobjectworker (EURUSD,H1)        129912254742671350: OnDeinit
2018.11.14 15:11:59.272 multiwebobjectworker (EURUSD,H1)        129912254742671349: Done in 297ms
2018.11.14 15:11:59.334 multiwebindicator (EURUSD,H1)   129912254742671348: Result code 200
2018.11.14 15:11:59.334 multiwebindicator (EURUSD,H1)   129912254742671348: Reading result \Experts\multiwebobjectworker.ex5::WRS_0_129912254742671349
2018.11.14 15:11:59.334 multiwebindicator (EURUSD,H1)   129912254742671348: Got 12688 bytes in response
2018.11.14 15:11:59.334 multiwebindicator (EURUSD,H1)   GET https://google.com/
2018.11.14 15:11:59.334 multiwebindicator (EURUSD,H1)   Received 790 bytes in header, 11813 bytes in document
2018.11.14 15:11:59.350 multiwebobjectworker (EURUSD,H1)        129912254742671349: OnDeinit
2018.11.14 15:11:59.833 multiwebobjectworker (EURUSD,H1)        129912254742671351: Done in 749ms
2018.11.14 15:11:59.833 multiwebindicator (EURUSD,H1)   129912254742671348: Result code 200
2018.11.14 15:11:59.833 multiwebindicator (EURUSD,H1)   129912254742671348: Reading result \Experts\multiwebobjectworker.ex5::WRS_0_129912254742671351
2018.11.14 15:11:59.833 multiwebindicator (EURUSD,H1)   129912254742671348: Got 45212 bytes in response
2018.11.14 15:11:59.833 multiwebindicator (EURUSD,H1)   GET https://www.startpage.com/
2018.11.14 15:11:59.833 multiwebindicator (EURUSD,H1)   Received 822 bytes in header, 44307 bytes in document
2018.11.14 15:11:59.849 multiwebindicator (EURUSD,H1)   > > > Async WebRequest workers finished 3 tasks in 1357ms
2018.11.14 15:11:59.880 multiwebobjectworker (EURUSD,H1)        129912254742671351: OnDeinit

I'm attaching the sources here as well.

Also please check for updated versions of include files from fxsaber, which are used in dependencies - they may contain bugfixes and speedups.

Files:
 
Awesome article. Openning doors for a lot of possibilities. Thanks you.
 

Absolutely amazingly incredible article !!!

Congratulations and thank you, @marketeer !

 

I can't get it to run.

Error 4002.

After a little analysis I found that the wyker does not receive the URL. Instead it receives a null value

 
Someone Else:

I can't get it to work.

Error 4002.

After a little analysis I found that the wyker does not receive the URL. Instead it receives a null value

What exactly programmes/libraries were used (you can just attach them)? Specific logs are also needed. MT5 version. Try in other earlier versions of MT5.

 

Everything is simple. I downloaded the archive from the site and ran in the diagnostic mode described in the text, changing only the sites, instead of three, specified only google.com prescribed in the webquest of the terminal.

version 5 build 2085 is not the latest at the moment. before this version I don't remember, it was also the latest at that moment.

from logs

2019.07.04 14:11:31.882 multiwebclient (AUDUSD,M5) > > > > Standard WebRequest 1 calls finished in 141ms

2019.07.04 14:11:31.882 multiwebclient (GBPUSD,M5) Pool manager transfers taQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\multiwebclient.ex5::AUDUSD_PERIOD_M5_1_131797648225084732

2019.07.04 14:11:31.883 multiwebclient (AUDUSD,M5) Accepted: taQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\multiwebclient.ex5::AUDUSD_PERIOD_M5_1_131797648225084732 after 0 retries

2019.07.04 14:11:31.883 multiweb (GBPUSD,M5) 131797648225084729: Reading request taQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\multiwebclient.ex5::AUDUSD_PERIOD_M5_1_131797648225084732

2019.07.04 14:11:31.883 multiweb (GBPUSD,M5) 131797648225084729: Got 0 bytes in request

2019.07.04 14:11:31.883 multiweb (GBPUSD,M5) 131797648225084729: 0

2019.07.04 14:11:31.883 multiwebclient (AUDUSD,M5) WebRequest error code 4002

2019.07.04 14:11:31.890 multiwebclient (GBPUSD,M5) Result code from 131797648225084729: 4002, now idle

2019.07.04 14:11:31.890 multiweb (GBPUSD,M5) 131797648225084729: Failed with code 4002


Replaced Resource date as it was in the comments above the situation has not changed.

In principle you can repeat it yourself and check how it works.....

 
Someone Else:

Everything is simple. I downloaded the archive from the site and ran in the diagnostic mode described in the text, changing only the sites, instead of three, specified only google.com prescribed in the webquest of the terminal.

Version 5 build 2085 is not the latest at the moment. I don't remember the version before, it was also the latest at that moment.

from logs

2019.07.04 14:11:31.882 multiwebclient (AUDUSD,M5) > > > > Standard WebRequest 1 calls finished in 141ms

2019.07.04 14:11:31.882 multiwebclient (GBPUSD,M5) Pool manager transfers taQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\multiwebclient.ex5::AUDUSD_PERIOD_M5_1_131797648225084732

2019.07.04 14:11:31.883 multiwebclient (AUDUSD,M5) Accepted: taQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\multiwebclient.ex5::AUDUSD_PERIOD_M5_1_131797648225084732 after 0 retries

2019.07.04 14:11:31.883 multiweb (GBPUSD,M5) 131797648225084729: Reading request taQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\multiwebclient.ex5::AUDUSD_PERIOD_M5_1_131797648225084732

2019.07.04 14:11:31.883 multiweb (GBPUSD,M5) 131797648225084729: Got 0 bytes in request

2019.07.04 14:11:31.883 multiweb (GBPUSD,M5) 131797648225084729: 0

2019.07.04 14:11:31.883 multiwebclient (AUDUSD,M5) WebRequest error code 4002

2019.07.04 14:11:31.890 multiwebclient (GBPUSD,M5) Result code from 131797648225084729: 4002, now idle

2019.07.04 14:11:31.890 multiweb (GBPUSD,M5) 131797648225084729: Failed with code 4002


Replaced the Resource date as it was in the comments above the situation has not changed.

In principle you can repeat it yourself and check how it works.....

Could not reproduce. Here is the log from running on build 2093:

2019.07.06 23:13:31.313 multiweb (EURUSD,H1)    OnInit 132069173221452536
2019.07.06 23:13:31.313 multiweb (EURUSD,H1)    WebRequest Pool Manager started in 132069173221452536
2019.07.06 23:13:32.810 multiweb (EURUSD,H1)    OnInit 132069176123428674
2019.07.06 23:13:32.810 multiweb (EURUSD,H1)    WebRequest Worker started in 132069176123428674; manager in 132069173221452536
2019.07.06 23:13:32.998 multiweb (EURUSD,H1)    OnInit 132069176125768678
2019.07.06 23:13:32.998 multiweb (EURUSD,H1)    WebRequest Worker started in 132069176125768678; manager in 132069173221452536
2019.07.06 23:13:33.169 multiweb (EURUSD,H1)    OnInit 132069176127796682
2019.07.06 23:13:33.169 multiweb (EURUSD,H1)    WebRequest Worker started in 132069176127796682; manager in 132069173221452536
2019.07.06 23:14:36.159 multiwebclient (GBPJPY,H1)      > > > Standard WebRequest 3 calls finished in 874 ms
2019.07.06 23:14:36.159 multiweb (EURUSD,H1)    Pool manager transfers \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_1_132069176509557415
2019.07.06 23:14:36.159 multiweb (EURUSD,H1)    132069176123428674: Reading request \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_1_132069176509557415
2019.07.06 23:14:36.159 multiwebclient (GBPJPY,H1)      Accepted: \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_1_132069176509557415 after 0 retries
2019.07.06 23:14:36.159 multiweb (EURUSD,H1)    Pool manager transfers \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_2_132069176509557415
2019.07.06 23:14:36.159 multiwebclient (GBPJPY,H1)      Accepted: \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_2_132069176509557415 after 0 retries
2019.07.06 23:14:36.159 multiweb (EURUSD,H1)    132069176125768678: Reading request \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_2_132069176509557415
2019.07.06 23:14:36.159 multiweb (EURUSD,H1)    132069176123428674: Got 64 bytes in request
2019.07.06 23:14:36.159 multiweb (EURUSD,H1)    132069176123428674: GET https://google.com/ User-Agent: n/a 5000 
2019.07.06 23:14:36.159 multiweb (EURUSD,H1)    132069176125768678: Got 60 bytes in request
2019.07.06 23:14:36.159 multiweb (EURUSD,H1)    132069176125768678: GET https://ya.ru User-Agent: n/a 5000 
2019.07.06 23:14:36.174 multiweb (EURUSD,H1)    Pool manager transfers \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_3_132069176509557415
2019.07.06 23:14:36.174 multiwebclient (GBPJPY,H1)      Accepted: \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_3_132069176509557415 after 0 retries
2019.07.06 23:14:36.174 multiweb (EURUSD,H1)    132069176127796682: Reading request \Experts\multiwebclient.ex5::GBPJPY_PERIOD_H1_3_132069176509557415
2019.07.06 23:14:36.174 multiweb (EURUSD,H1)    132069176127796682: Got 72 bytes in request
2019.07.06 23:14:36.174 multiweb (EURUSD,H1)    132069176127796682: GET https://www.startpage.com/ User-Agent: n/a 5000 
2019.07.06 23:14:36.283 multiwebclient (GBPJPY,H1)      132069176509557415: Result code 200
2019.07.06 23:14:36.283 multiwebclient (GBPJPY,H1)      132069176509557415: Reading result \Experts\multiweb.ex5::WRR_132069176125768678
2019.07.06 23:14:36.283 multiweb (EURUSD,H1)    132069176125768678: Done in 125 ms
2019.07.06 23:14:36.283 multiweb (EURUSD,H1)    Result code from 132069176125768678: 200, now idle
2019.07.06 23:14:36.283 multiwebclient (GBPJPY,H1)      132069176509557415: Got 17664 bytes in response
2019.07.06 23:14:36.283 multiwebclient (GBPJPY,H1)      GET https://ya.ru
2019.07.06 23:14:36.283 multiwebclient (GBPJPY,H1)      Received 4043 bytes in header, 13540 bytes in document
2019.07.06 23:14:36.439 multiwebclient (GBPJPY,H1)      132069176509557415: Result code 200
2019.07.06 23:14:36.439 multiwebclient (GBPJPY,H1)      132069176509557415: Reading result \Experts\multiweb.ex5::WRR_132069176123428674
2019.07.06 23:14:36.439 multiweb (EURUSD,H1)    Result code from 132069176123428674: 200, now idle
2019.07.06 23:14:36.439 multiweb (EURUSD,H1)    132069176123428674: Done in 281 ms
2019.07.06 23:14:36.439 multiwebclient (GBPJPY,H1)      132069176509557415: Got 12744 bytes in response
2019.07.06 23:14:36.439 multiwebclient (GBPJPY,H1)      GET https://google.com/.
2019.07.06 23:14:36.439 multiwebclient (GBPJPY,H1)      Received 736 bytes in header, 11927 bytes in document
2019.07.06 23:14:36.455 multiwebclient (GBPJPY,H1)      132069176509557415: Result code 200
2019.07.06 23:14:36.455 multiwebclient (GBPJPY,H1)      132069176509557415: Reading result \Experts\multiweb.ex5::WRR_132069176127796682
2019.07.06 23:14:36.455 multiweb (EURUSD,H1)    Result code from 132069176127796682: 200, now idle
2019.07.06 23:14:36.455 multiweb (EURUSD,H1)    132069176127796682: Done in 280 ms
2019.07.06 23:14:36.471 multiwebclient (GBPJPY,H1)      132069176509557415: Got 32520 bytes in response
2019.07.06 23:14:36.471 multiwebclient (GBPJPY,H1)      GET https://www.startpage.com/
2019.07.06 23:14:36.471 multiwebclient (GBPJPY,H1)      Received 956 bytes in header, 31482 bytes in document
2019.07.06 23:14:36.471 multiwebclient (GBPJPY,H1)      > > > Async WebRequest workers [3] finished 3 tasks in 312 ms

Look for a problem in your settings or system.

 

I confirm that on default settings the script does not work - I get the same"WebRequest error code 4002...".


MetaTrader 5

Version: 5.00 build 2093

02 Jul 2019


===cut here===

2019.07.23 00:47:37.182 multiwebclient (USDJPY,H1) Accepted: aQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\multiwebclient.ex5::USDJPY_PERIOD_H1_2_128968169154443359 after 0 retries

2019.07.23 00:47:37.182 multiwebclient (USDJPY,H1) WebRequest error code 4002

===cut here===


Торговые советники и собственные индикаторы - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
Торговые советники и собственные индикаторы - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
  • www.metatrader5.com
Среди программ для автоматического трейдинга можно выделить две большие категории: торговые роботы и индикаторы. Первые предназначены для совершения торговых операций на рынках, а вторые — для анализа котировок и выявления закономерностей в их изменении. При этом индикаторы могут использоваться непосредственно в роботах, образуя полноценную...
 
Igor K:

I confirm that on default settings the script does not work - I get the same"WebRequest error code 4002"....


MetaTrader 5

Version: 5.00 build 2093

02 Jul 2019


===cut here===

2019.07.23 00:47:37.182 multiwebclient (USDJPY,H1) Accepted: aQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\multiwebclient.ex5::USDJPY_PERIOD_H1_2_128968169154443359 after 0 retries

2019.07.23 00:47:37.182 multiwebclient (USDJPY,H1) WebRequest error code 4002

===cut here===


Please write more details - OS version, antivirus, etc. I'm on Win 7, MT5 build 2093 works fine as shown above.

Basically, the question is for MQ, because the error is related to an "internal call", but I don't believe in help - support is closed.

The source code of the article is open source, so try to solve the problem on the machine where the error is reproduced.