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:
If Prev = High (previous price is the High price), the following loop is used:
Here: N1, N2 — reference points in one loop; Intermediate TicksIntermediate ticks between reference points are generated according to the following rules:
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:
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 20002015, MetaQuotes Software Corp.