Download MetaTrader 5

LifeHack for Traders: Indicators of Balance, Drawdown, Load and Ticks during Testing

28 July 2016, 10:11
Karputov Vladimir
6 311

Table of Contents


You may run visual testing in the MetaTrader 5 Strategy Tester for different purposes. For example, sometimes you may want to see how the balance and equity of a trading account were changing during testing. Sometimes, you may need to visually monitor the possibility of trend emergence while testing in the "Every tick based on real ticks" mode. It means a separate LifeHack indicator is required in each case. We will run different indicators in the MetaTrader 5 Strategy Tester, while saving the chart template as tester.tpl (the template of a chart, on which testing results are displayed).

The common rules for the use of indicators in the tester:

  1. Run one of the LifeHack indicators on the chart.
  2. Save the template as tester.tpl.
  3. Start visual testing.

There is another way to save the template — by running the following script:

//|                                  ChartSaveTemplateTester_tpl.mq5 |
//|                              Copyright © 2016, Vladimir Karputov |
//|                                  |
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link      ""
#property version   "1.00"
//| Script program start function                                    |
void OnStart()
//--- save the current chart in a template
      MessageBox("Error SaveTemplate #"+IntegerToString(GetLastError()));
      MessageBox("Template \"tester.tpl\" overwritten!");

In this script, the template name "tester" is hard coded, because the script is highly specialized. You can also assign a hot key for the script:


Fig. 1. Assigning a hot key 

The LifeHack Ticks indicator

The indicator of ticks LifeHack Ticks shows the last 300 ticks:

//--- indicator buffers
double         AskBuffer[];
double         BidBuffer[];
double         AskBufferTemp[];
double         BidBufferTemp[];
//--- parameters
int            InpVisible=300;
//| Custom indicator initialization function                         |
int OnInit()

You can change the InpVisible parameter. However, I would not recommend using a value greater than 1000, because this would cause an unnecessary load on the terminal.

By the way, the indicator also shows the difference between the real and emulate ticks:

real ticks

Fig. 2. "Every tick based on real ticks"

all ticks

Fig. 3. "Every tick"

The below video demonstrates the difference between the two types of tick generation:         


Also, the LifeHack Ticks indicator shows the time of the last tick in its subwindow. This makes it possible to jump to the desired date and view appropriate ticks in the step-by-step mode in the Strategy Tester.

For example, you may want to view testing on ticks starting with 2016.06.03 15:00 on the chart of EURUSDH1:


Fig. 4. Analyzing ticks from 2016.06.03 15:00


1. Run the LifeHack Ticks indicator and save the chart template as tester.tpl. Right click on the chart and select "Templates - "Save Template...". In the Explorer, select the template tester.tpl (if there is no such template, then you should type this name) and click "Save":

Fig. 5. Saving the chart template

2. In the MetaTrader 5 Strategy Tester, specify the time interval so that it includes 2016.06.03, select EURUSD, choose testing timeframe H1 and testing type "Every tick based on real ticks":

Fig. 6. Testing.

3. Start visual testing.

4. In the tester, click on "Pause Visualization, Space" (①), in the "Skip to" field specify 2016.06.03 14:59 (②), and then switch ticks in the step-by-step mode (③):

Fig. 7. Jump to the desired date

or start testing at a low speed. 

The LifeHack Balance Equity indicator

The LifeHack Balance Equity indicator visualizes how the trade account balance and equity are changing.

LifeHack Balance Equity

Fig. 8. The LifeHack Balance Equity indicator

The LifeHack Drawdown Load indicator

The LifeHack Drawdown Load indicator allows you to review the drawdown and the deposit load during the visual testing process. The drawdown is calculated by the following formula:


Running both LifeHack Drawdown Load and LifeHack Balance Equity in the MetaTrader 5 Strategy Tester:

LifeHack Drawdown Load

Fig. 9. The LifeHack Drawdown Load indicator

For convenience, the types of drawing (line and histogram) are added to the indicator label names. Another important moment: labels "Drawdown (line)" and "Load (histogram)" preserve their highest value on the current bar. That is, if the maximum deposit load on the current bar was 80%, and then it fell to 10%, the label of "Load (histogram)" would still show the maximum value of 80%.


I hope that the approach of creating the tester.tpl template with the required indicators of the LifeHack series will allow you to visually detect the strengths and weaknesses of the applications that you test. 

Translated from Russian by MetaQuotes Software Corp.
Original article:

Step on New Rails: Custom Indicators in MQL5 Step on New Rails: Custom Indicators in MQL5

I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.

Here Comes the New MetaTrader 5 and MQL5 Here Comes the New MetaTrader 5 and MQL5

This is just a brief review of MetaTrader 5. I can't describe all the system's new features for such a short time period - the testing started on 2009.09.09. This is a symbolical date, and I am sure it will be a lucky number. A few days have passed since I got the beta version of the MetaTrader 5 terminal and MQL5. I haven't managed to try all its features, but I am already impressed.

False trigger protection for Trading Robot False trigger protection for Trading Robot

Profitability of trading systems is defined not only by logic and precision of analyzing the financial instrument dynamics, but also by the quality of the performance algorithm of this logic. False trigger is typical for low quality performance of the main logic of a trading robot. Ways of solving the specified problem are considered in this article.

Using text files for storing input parameters of Expert Advisors, indicators and scripts Using text files for storing input parameters of Expert Advisors, indicators and scripts

The article describes the application of text files for storing dynamic objects, arrays and other variables used as properties of Expert Advisors, indicators and scripts. The files serve as a convenient addition to the functionality of standard tools offered by MQL languages.