
Knowledge is power
How to determine if an indicator is suitable for Expert AdvisorsMost Expert Advisors use one or more indicators. MetaTrader platform delivers a set of build‑in indicators and additionally a possibility to write own indicators (Custom Indicators). Unfortunately, a lot of indicators that can be found in the Internet can't be used by Expert Advisors, because for example they are badly implemented or they only draw objects and can't be used in a standard way. The other common reason for disqualifying an indicator is the usage of data taken from the future in calculations (not only current and past candles). For example to calculate the value of 5‑period simple moving average for a bar at 2008.01.01 12:00 on a H1 chart, we need bars from 8:00, 9:00, 10:00, 11:00 and 12:00. Now, imagine that certain indicator uses bars from 8:00 to 14:00 to display value at 2008.01.01 12:00. So it uses 2 bars taken from the future. How is it possible? It is possible only on the basis of historical data. In live trading these 2 future bars of course won't be available. That's why this indicator will look different on a historical data and after some time in live trading. Sometimes such indicators change values not only for the most recent bar. We call such behaviour "redrawing". Generally, such indicators aren't suitable for an Expert Advisors. In rare cases, some of indicators that redraw can be used, but it must be fully conscious. A good example of an indicator, that redraws but can be used (but very consciously) in Expert Advisors, is ZigZag, which is provided with MetaTrader terminal. Below there are 3 steps which will help you test indicators and check if they are suitable for an Expert Advisors. Step 1 – Data Window
If, in spite of above setting, an indicator is not displayed in the Data Window, it is generally not suitable for Expert Advisors. Of course, to every rule there is an exception. If your indicator only draws objects (for example Pivot levels for only current day), it won't be displayed in the Data Window. An Expert Advisor can retrieve values from objects but backtesting of such Expert Advisor will be impossible or very limited. In fact, it will be possible only in visual mode after manual attaching this indicator to a chart. Also Optimization won't be possible. That's why such indicators aren't recommended for Expert Advisors. However, they can be successfully used in a manual trading. Step 2 – Historical view vs. Current view
If we attached this indicator at 2008.08.13, it would look like in the lower chart. But if we attached this indicator at 2008.08.08 and let it run for 3 days, it would look like in the upper chart. The difference is obvious. In live trading this indicator gives only a few signals in spite of many perfect signals on a historical quotations. For a properly implemented indicator, both charts must be identical. How to conduct such test? Very simple:
For indicators, that are displayed on a main chart just after conducting the whole test, open a new chart and compare both views by switching from one chart to the other. You don't have to wait a few hours or days for the result. To speed up examination you can use Visual mode in backtester – for example any Expert Advisor, although the best will be one that does absolutely nothing. Download VisualTester that only places vertical line at the beginning (VisualTester.ex4).
Step 3 – IndicatorTesterThis is the final step. It enables us to eliminate most of wrong indicators that have positively passed two previous steps. IndicatorTester should be used wisely. It simulates the usage of an indicator in an Expert Advisor. With every tick, it compares all indicator's buffers to their previous values and checks how many indicator's values (expressed in bars) have been changed. For most proper indicators the result (called Redraw Factor) will be equal to 1 or 0. Redraw Factor is the maximum amount of changed bars for whole test and all buffers. Redraw Factor = 1 means that the indicator changes only its most recent value. Values of completed bars are not changed. Redraw Factor = 0 means that the indicator never changes its values. A good example of such indicator is the moving average based on open prices (not close prices). Because open price remains unchanged, the result of calculations is also the same. You can find indicators that are implemented correctly, but their Redraw Factor is equal to 2. These indicators are visualized as one line, but in two colours. For example, one colour corresponds to the rising part of the line and the other colour to the descending part. This is because each colour of this indicator requires separate buffer – this is the only way to implement such visualization in MetaTrader. However, to avoid any ambiguities, such indicators should be visualized as dots in two colours, not lines. Additionally, lines can overlap on each other, which can lead to seemingly strange behaviour of an Expert Advisor. Overlapping of lines can be detected via the Data Window – more than one buffer will be active at the same time. Also indicators, that are based on other indicators from higher timeframes, can have Redraw Factor higher than 1. For example, if an indicator on H1 chart uses other indicator from H4 timeframe, it can have Redraw Factor equal to 4 instead of 1 (there are 4 H1 candles for one H4 candle). The usage of IndicatorTester needs some explanation. File IndicatorTester.ex4 should be placed as other Expert Advisors in experts subdirectory. As it is a kind of Expert Advisor, which doesn't trade but checks indicators, it also has its own parameters.
IndicatorTester should be run for at least 100 bars. The more, the better. It can be used both in live trading and backtester (Visual mode). Examples:Note: Analysed indicator is drawn on a chart automatically after the end of a backtest (after clicking on the Stop button). If you want to observe the indicator during test, you have to attach it to the chart by yourself.
Summary
|
|