Generation of TicksTicks are required for testing and optimizing Expert Advisors, because the Expert Advisor works on ticks. Tick data are generated by the tester based on cached minute records in the integer format. It means, the tester copies the required history data from the terminal and transfers them to the integer format to speed up calculations.
Generation of Ticks Depending on the Tick VolumeThe generation of tick differs for bars with different tick volumes: Tick Volume = 1For bars with the tick volume equal to one, ticks are not generated, a tick with the value of its Close price is written for it: Tick Volume = 2Also ticks are not generated for bars with two ticks. First a tick with the Open price is written, and then the tick with the Close price is written: Tick Volume >= 3For bars with 3 or more ticks, there are different schemes of tick generation depending on their number. Scheme of Bar ProgressFour different schemes are possible for bars with three or more ticks:
Generation of Ticks for Bars with Three or More TicksTicks are generated based on reference points. The number of such points cannot exceed the tick volume, and cannot be larger than 11 (the point of the Open price is not taken into account). Reference points are divided into three parts: those for forming open shadow, the candlestick's range (between its High and Low) and the close shadow. Depending on the number of ticks, the following variants of reference points distribution are possible:
The Ideal Distribution (353)Reference points are calculated as the number of points from the open price. The ideal distribution of points (353) is calculated the following way: Bull Candlestick
Bear Candlestick
Doji CandlesticksIf a candlestick is doji (Close = Open), previous candlesticks are analyzed. If the previous candlestick was rising, this one is considered falling, and vice versa. Plotting a Shadow on Three PointsIf three points are used for generating a shadow, and integer values of 3/4 of the shadow size and 1/2 of the shadow size are equal (this happens when the difference between the Open and Low or Open and High is not more than 2 points, i.e. distances of price steps forward and backward are equal), then the shadow generation changes the following way: Bull Candlestick
Bear Candlestick
Plotting a Shadow on Two PointsIf a shadow is generated based on two points, the generation is performed the following way: Bull Candlestick
Bear Candlestick
Plotting the Candlestick RangeThe candlestick range is generated by waves in loops. If Prev = Low (previous price is the Low price), the following loop is used: •N1 = Prev + Step •N2 = Prev + Step — 1 •Prev = N2 If Prev = High (previous price is the High price), the following loop is used: •N1 = Prev — Step •N2 = Prev — Step + 1 •Prev = N2 Here: N1, N2 — reference points in one loop; Intermediate TicksIntermediate ticks between reference points are generated according to the following rules: •If the number of ticks is larger than the number of pips between the reference points, "saw" is generated (initial value +/— 1). •If the number of pips between reference points is large enough, a linear sequence of ticks is generated. Tick Generation ModesIn the window of the strategy tester settings, you can select a mode of generation of ticks. The following variants are available: Every TickIn this mode all ticks are generated — OHLC and intermediate ticks. The procedure of such generation of ticks is described above. 1 Minute OHLCIn this mode only OHLC ticks of 1 minute bars are generated. If the tick volume of a candlestick is greater than 4, then only four prices (Open, High, Low and Close) are generated. If the tick volume is less than 4, then the rules of generating, described above, are applied.
In fact, OHLC prices exist in history data. Thus, only the time when Open, High, Low and Close ticks were received, is generated during testing, the price values are taken from the history. Open Prices OnlyIn this mode, OHLC prices of bars of the timeframe selected for testing are generated. The Expert Advisor function OnTick() runs only at the beginning of the bar (at the Open price). Due to this feature, Stop Levels and pending orders may trigger at a price different from the specified one (especially when testing at higher timeframes). But this allows you to quickly run an evaluation test of an Expert Advisor.
There are some limitations on the "Open Prices Only" mode: •You cannot use the Random Delay execution mode. •In the tested Expert Advisor, you cannot access data of the timeframe lower than that used for testing/optimization. For example, if your run testing/optimization on the H1 period, you can access data of H2, H3, H4 etc., but not M30, M20, M10 etc. In addition, the higher timeframes that are accessed must be multiple of the testing timeframe. For example, if you run testing in M20, you cannot access data of M30, but it is possible to access H1. These limitations are connected with the impossibility to obtain data of lower or nonmultiple timeframes out of the bars generated during testing/optimization. •Limitations on accessing data of other timeframes also apply to other symbols whose data are used by the Expert Advisor. In this case the limitation for each symbol depends on the first timeframe accessed during testing/optimization. Suppose, during testing on EURUSD H1, an Expert Advisor accesses data of GBPUSD M20. In this case the Expert Advisor will be able to further use data of EURUSD H1, H2, etc., as well as GBPUSD M20, H1, H2 etc.
Mathematical CalculationsThis mode allows you using the Strategy Tester for mathematical computations. It does not require and therefore does not load historical data and information about symbols, and it does not generate ticks. In the tested Expert Advisors, only OnInit(), OnTester() and OnDeinit() are called sequentially. In this mode, the Custom optimization criterion is automatically applied as the optimization criterion. All the fields in the tester settings, except for the optimization mode and Expert Advisor selection, become inactive. Mathematical calculations are useful for search of an extremum of a mathematical function, whose value should be returned from OnTester(). Optimization is conducted for finding the maximum value of the function. With a large number of combinations of input parameters of a mathematical function, it is recommended to use the "Genetic algorithm". This allows us to significantly accelerate the search for an extremum.

MetaTrader 5 — a complex trading platform for providing brokerage services on the retail Forex market.
Copyright 20002014, MetaQuotes Software Corp.