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

TesterBenchmark - MetaTrader 5용 라이브러리

조회수:
3177
평가:
(23)
게시됨:
2017.11.03 11:53
\MQL5\Include\ \MQL5\Experts\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

When writing different code versions, you may need to measure their impact on the overall performance of the Expert Advisor in the tester. This allows you to understand how optimal the code is, compared to other programs, and provides prerequisites for further fast optimization of Expert Advisors. This approach allows us to identify the "bottleneck" in the EA performance.

The MetaTrader 5 provides an excellent function for profiling Expert Advisors on historical data. But it has some disadvantages: it is slow (in the visual mode), and the final result is presented in relative units, i.e. it is not possible to compare performance in absolute terms.

Also, in MetaTrader 5, the EA is executed on a local Agent even during a single run without visualization. Sometimes a large part of testing time is taken to synchronize the terminal with a corresponding local agent. Therefore, time data from the following lines

Core 1  EURUSD,M1: 3387955 ticks, 52608 bars generated. Environment synchronized in 0:00:01.389. Test passed in 0:00:09.422 (including ticks preprocessing 0:00:00.187).
Core 1  EURUSD,M1: total time from login to stop testing 0:00:10.811 (including 0:00:01.389 for history data synchronization)

are a poor representation of the net EA/tester performance, and can differ much in different runs.

The net operation time of the Strategy Tester is the time from the first Tick event (the first OnTick) till the last tick in the tested interval. Immediately after this interval, the tester calls OnTester (followed by OnDeinit).


The net time of a testing run in the Strategy Tester

The library allows adding to the EA code one line

#include <TesterBenchmark.mqh>

and to obtain in logs the data on the tester's net performance.

Core 1  2017.07.21 23:59:59   Interval = 8.842 s., Count = 3387955, 383166.1 unit/sec
Core 1  EURUSD,M1: 3387955 ticks, 52608 bars generated. Environment synchronized in 0:00:01.389. Test passed in 0:00:09.422 (including ticks preprocessing 0:00:00.187).
Core 1  EURUSD,M1: total time from login to stop testing 0:00:10.811 (including 0:00:01.389 for history data synchronization)

Moreover, if in the tester you switch from a single run to an optimization mode (there is no need to specify optimization ranges for MetaTrader 5), the library will run the EA for the specified number of times and will generate the tester performance statistics, based on which you can understand the pure performance of the tester.

------
OnTesterInit
i = 0 Pass = 0 OnTester = 8.687 s.: Count = 3387955, 390002.9 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000
i = 1 Pass = 1 OnTester = 8.702 s.: Count = 3387955, 389330.6 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000
iMin = 0 Results[iMin] = 8.687s.
iMax = 1 Results[iMax] = 8.702s.
Amount = 2 Mean = 8.694 s. - 83.89%
OnTesterDeinit
------
Interval = 20.729 s., Count = 0, 0.0 unit/sec

In this case, it is clear that there were two starts on the same local Agent. The minimum, maximum and average calculation time is shown. The total time of optimization (Interval) is also shown. The percent characteristics (83.89%) shows how much of the total optimizer time is taken on the average by the pure operation of the tester (time required for synchronization with Agents is taken into account).



OnTick profiling

By adding one more line

#define PROFILER_OnTick // Measures the net time of all OnTick executions, may slightly slows down the total operation
#include <TesterBenchmark.mqh>

you can see time spent on the execution of OnTick, not taking into account time taken to simulate trading environment, performance, etc.

------
OnTesterInit
i = 0 Pass = 0 OnTester = 9.540 s.: OnTick Profiler: Count = 3387955, Interval = 8.079 s., 419359.4 unit/sec , Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000
i = 1 Pass = 1 OnTester = 9.471 s.: OnTick Profiler: Count = 3387955, Interval = 8.029 s., 421956.9 unit/sec , Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000
iMin = 1 Results[iMin] = 9.471s.
iMax = 0 Results[iMax] = 9.540s.
Amount = 2 Mean = 9.505 s. - 98.86%
OnTesterDeinit
------
Interval = 19.231 s., Count = 0, 0.0 unit/sec



Example

The library is provided with an example EA (MQL4/5) with a header, which helps to understand one of the practical applications of the library.

#include <TesterBenchmark.mqh>

// If both include lines below are commented, then the trade logic is written in pure MQL5 - trade API
// Otherwise, an uncommented line is the API wrapper that is used.
// TesterBench shows the performance of each of the three APIs.
// #include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006
// #include <Trade\Trade.mqh>

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/18804

Chart Save Template Chart Save Template

The script saves current chart settings to a template with the specified name.

Report Report

The MetaTrader 4/5 library allows generating reports based on the trading history.

Four_MA_Strength Four_MA_Strength

The indicator displays trend power and direction based on four moving averages.

Mikahekin_HTF Mikahekin_HTF

The Mikahekin indicator with the timeframe selection option available in input parameters.