거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
지표

Pseudo-Indicator with Asynchronous Multi-Threaded Calculations Demo - MetaTrader 5용 지표

조회수:
11007
평가:
(19)
게시됨:
2020.01.16 20:13
\MQL5\Include\
TypeToBytes.mqh (20.54 KB) 조회
\MQL5\Include\fxsaber\
Resource.mqh (0.64 KB) 조회
Convert.mqh (3.42 KB) 조회
Expert.mqh (13.27 KB) 조회
\MQL5\Experts\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

This indicator is a pseudo-indicator w/o buffers. Its only purpose is to demonstrate multi-threaded calculations technique. The indicator can issue commands for lenghty calculations which are performed in separate threads, created for chart objects with worker expert adviser. The classes provided in the included header file - MultiThreadedObjectWorker.mqh - will automatically create the chart objects and apply template with specified worker expert adviser in each object. After calculation is done the object is automatically removed from the chart.

This example is intended for users with programming background.

The idea comes from the article about Multi-Threaded Asynchronous WebRequests. Please, find all technical details on how the messages (events) are dispatched, and how resources are used to pass data between charts in the article.

The indicator utilizes more "compact" implementation of the techique than in the article by using chart objects instead of full-fledged chart windows. You may find details on the forum.

Make sure the worker expert adviser - MultiThreadedObjectWorker - is compiled before you compile and run the indicator itself - MultiThreadedIndicator.

Input parameters

  • sinput int _Cores = 1; - number of threads to utilize (don't use more than available physical cores)
  • sinput int _Tasks = 1; - number of pseudo-tasks to execute in parallel (use number larger than number of cores to see parallel performance)
  • input string MultiThreadedScriptPath = "Experts\\MultiThreadedObjectWorker.ex5"; - must indicate the pathname of the worker expert adviser

Each pseudo-task calculates a bunch of sqrt functions (for demo purposes only). This can be changed in your MQL projects to any other time-consuming algorithms.

To start parallel calculations after the indicator is attached to a chart, please, click the chart. All important phases of the process (both in client and worker MQL5 programs) are logged.

The client MQL programm issuing parallel calculations requests can be not indicators only but expert advisers as well. Scripts and services are not supported by the platrform.

Using the header file MultiThreadedObjectWorker.mqh you should implement your own data marshalling between MQL5-client and the worker expert adviser.

Here is 2 examples of the logs.

Execution of 4 tasks on 2 cores (2 threads in parallel)

Execution of 4 tasks on 2 cores (2 threads in parallel)

When running 4 tasks on 2 cores there are 2 parallel threads, that provides twice as fast execution as on 1 cores (compare 3354ms above and 6240ms below).

Execution of 4 tasks on 1 core (single thread - standard MQL program)

Execution of 4 tasks on 1 core (single thread - standard MQL program)

More cores - more speed.



    Price in polar coordinate system Price in polar coordinate system

    Just for experiment and to demonstrate the possibilities of Canvas. The price is drawn in the polar coordinate system by winding circles.

    Cross Cross

    Simple code for Candle Cross above or below Conditions..

    3D Spiral Quotes 3D Spiral Quotes

    Demonstration of Canvas's capabilities using 3D spiral quotes as an example.

    CHistoryPositionInfo Class CHistoryPositionInfo Class

    A class for easy access to the closed position properties.