• Overview
  • Reviews (1)
  • Comments (5)
  • What's new

Testing Honest Predictor

This simple Testing Honest Predictor (THP) Expert Advisor was created in order to easily and meaningfully test the Honest Predictor indicator (iHP) performances, within the MT4 Strategy Tester.

Given an asset and a timeframe, THP selects a part of the positions displayed by iHP and prints on the journal (screenshot #2) the percentage of winning positions as if they were executed by a user.

It accepts only positions for which iHP suggests a reliability level not "UNRELIABLE" and a probability higher than a given Minimum Accuracy.

From the tests done, the Honest Predictor indicator seems to avoid "naturally" unfavorable market conditions, although a multi-asset approach is needed to compensate for the low frequency of positions (note that the indicator payed version can be attached on as many charts as you want, at the same time).

THP Usage

Input Parameters:
  • Duration of Backtesting in days: the duration of the backtesting used by iHP to evaluate accuracy (=percentage of winning positions) and reliability level
  • Indicator Threshold: the limit above which iHP generates a position.
  • Expiry Time in bars: the expiration (in bars) for the positions generated by iHP.
  • Minimum Accuracy: minimum threshold of the backtesting iHP accuracy above which THP accepts the positions generated by iHP.
  • Verbosity Level: if =1 it also lists all the accepted position.

The first 3 parameters are just passed to the indicator (see here for a full description).

Set the testing period in the Strategy Tester, press Start (Open Price mode can be used) and THP will print on the journal (screenshot #2) the percentage of winning positions that you would have obtained by executing the indicator positions when its estimated accuracy is above the Minimum Accuracy and when the UNRELIABLE condition does not hold.

No trading orders are performed.

Interfacing iHP to an EA

For users who want to embed the iHP within an Expert Advisor, I report below a code example.

HistoryDays, Threshold and Expiration contain the 3 parameters values that have to be passed to the indicator.

Given a bar shift (> 0 and < HistoryDays*1440/Period()), the first 4 buffers can be read to check if iHP found a position at that bar or not:

string IndiName = "HistoryPredictor.ex4"; //name of the available iHP executable
double UpWon=iCustom(NULL,0,IndiName,HistoryDays,Threshold,Expiration,0,shift);
double DownWon=iCustom(NULL,0,IndiName,HistoryDays,Threshold,Expiration,1,shift);
double UpFail=iCustom(NULL,0,IndiName,HistoryDays,Threshold,Expiration,2,shift);
double DownFail=iCustom(NULL,0,IndiName,HistoryDays,Threshold,Expiration,3,shift);

They refer to: winning CALL positions (0), winning PUT positions (1), loser CALL positions (2) and loser PUT positions (3).

EMPTY_VALUE is returned if there is no position of that type at that shift.

Please note that the position outcome is known only if shift > Expiration, i.e. if it expired and the bar entered the backtesting period. Otherwise, while the outcome remains unknown, the position is recorded only in buffers 0 or 1.

WARNING: if you plan to use your EA in the Strategy Tester at shift=1, then intra-bar modeling is needed and Every tick mode must be set! This is because iHP generates positions on various ticks after the closing time of the bar at shift=1.

To obtain statistical information, both the total number of positions (6th buffer) and that of the winning ones (7th buffer) that were found within the iHP HistoryDays-long backtesting period can be read as:

int TotalHistoryPos = int( iCustom(NULL,0,IndiName,HistoryDays,Threshold,Expiration,5,shift ) );
int TotalHistoryWon = int( iCustom(NULL,0,IndiName,HistoryDays,Threshold,Expiration,6,shift ) );

For example, one could evaluate the accuracy and ignore the last indicator predicted position when this accuracy is unknown or below 70%:

if (TotalHistoryPos == 0 || double(TotalHistoryWon)/double(TotalHistoryPos) < 0.7) return;

Moreover, the p-value can be read from the 8th buffer, for instance to exclude UNRELIABLE conditions:

double pvalue = iCustom(NULL,0,IndiName,HistoryDays,Threshold,Expiration,7,shift);
if (pvalue >= 0.1) return;
Ovidiu Caslariu
2016.05.06 22:42 

User didn't leave any comment to the rating

Version 1.9 - 2015.08.10
It now optimizes and tests versions 2.4 and 2.5 of Honest Predictor (paid versions) with the possibility of handling both the built-in Honest Predictor (iHP) "self-optimizer" and the time management of signal emission.

Added parameters to deal with self-optimization (which regards the iHP threshold, the expiry time and the trend prediction mode):

- 'Self-Optimization Enabled' flag
- 'Self-Optimization Frequency (hours)' (determining how often the indicator is redrawn with the re-optimized parameters)
- 'Max Expiry Time in Self-Optimization (bars)' (the maximum expiry time checked by the self-optimizer).

Regarding the time management, five flags enabling/disabling signals emission on each weekday plus the 'Alert Time Slots' parameter were added to manage time alert emission.

All these parameters are passed "as is" to the indicator.

This allows a complete testing and "experimentation" of the indicator by the user. Internal iHP backtesting can also be ignored (and consequently, the self-optimizer as well) by setting 'Duration of the backtesting' to zero.
This can be done if one wants to replace the internal backtesting with the long-term backtesting done by the Testing Honest Predictor EA.

Please, notice that a frequent self-optimization can considerably slow down the EA.

Read periodically the product comments to see examples of usage.
Version 1.8 - 2015.07.03
It now optimizes and tests the ver. 2.3 of Honest Predictor (paid version) which has a faster (and more stable) execution in comparison with the previous version.
Version 1.7 - 2015.07.01
It now optimizes and tests the ver. 2.2 of Honest Predictor (paid version).

-Added "Trend Prediction Mode" parameter (to be passed to the iHP indicator) that allows the user to choose between the REVERSAL and CONTINUATION trend modes that iHP tries to predict (it won't change anymore during iHP execution).

- A simulation of the development of an initially given balance has been implemented, similarly to what normally done in backtesting forex trading Expert Advisors (see the added parameters below).

- Added "Initial Balance" parameter.

- Added "Single Position Investment" parameter. It represents the amount of money the EA simulates to invest in each position.
If "Risk Factor" is zero, then this investment will be always the same. Otherwise, this parameter is ignored and the investment will be determined automatically according to the "Risk Factor" and the balance
(see below).

- Added "Risk Factor" parameter (in %). If larger than 0, it represents the percentage of the balance that will be invested each time in a position by the EA.
If it is =0, then the investment won't change, being always equal to the "Single Position Investment" parameter.

-Added "Minimum Investment" and "Maximum Investment" parameters to allow the user to set the minimum and maximum values for the automatically determined investment (many brokers have a minimum threshold for the investment to be accepted).

-Now optimization maximizes the balance instead of the profit factor.

-Now, if "Verbosity" is =PRINT_BALANCE, in addition to positions outcomes, also the Balance and the Net Profit will be printed in the Journal every time a position expires.
If "Verbosity" is =SAVE_BALANCE, this information is also written on a file.
This file is saved as "tester\files\TestHonestPredictor.csv" and it is a CSV file, in which each line shows the expiry time of a position, the balance, the net profit and the amount of investment at the same time.
The user may want to use this file to plot a graphical representation (e.g. using Excel) of the Balance development, as it is done by the Strategy Tester with forex trading EA.

Comments will follow regarding the optimization procedure.
Version 1.6 - 2015.06.19
It now optimizes and tests the ver. 2.1 of Honest Predictor (paid version).

-IMPORTANT BUG CORRECTION: now the EA doesn't stop if sufficiently numerous bars are not immediately available to do backtesting. It continues execution until the number of bars is high enough. This allows to do backtesting and optimization on very long times (as is normally done for forex trading).

- Now optimization maximizes the profit factor (f) instead of accuracy. Here, f is defined as the ratio between the final balance and the investment for the single option (assumed to be always the same). It depends on the number of both won and lost positions and on the corresponding broker's payout percentages (see below).
Try the optimization by varying the 'Indicator Threshold' and the 'Expiry Time' and see the results (Optimization Graph in the Strategy Tester)!
It is also interesting to see how the profitability is heavily influenced by the spread (see below).

Comments will follow regarding the optimization procedure.

- Added "Spread" (in pips) parameter to be passed to the iHP indicator. See https://www.mql5.com/en/market/product/8700 (ver. 2.1 in "What's new" section).

- Added "Out-of-the-money" position payout parameter (in %, broker-dependent).

- Added "In-the-money" position payout parameter (in %, broker-dependent).
Version 1.5 - 2015.06.08
The possibility to exclude the internal backtesting of the Honest Predictor indicator (iHP) has been introduced: if the "Duration of backtesting in days" Expert parameter is set to 0, then this EA will accept all the positions suggested by iHP.
Thus, the "Minimum Accuracy" and the "Minimum Reliability Level" parameters will be just ignored.

This is especially useful when testing iHP on short timeframes (say, shorter than M15), on which the internal backtesting cannot be done with sufficiently long duration because the number of bars usually available on a chart is not large enough.
Version 1.4 - 2015.05.29
- It now includes Free ver. 2.0 of iHP for testing.
- Minor bugs corrected.
Version 1.3 - 2015.05.19
- Ver. 1.9 of the Free version of iHP included.

Read the Comment I posted on May, 7th, 2015
Version 1.2 - 2015.05.11
- Ver. 1.8 of the Free version of iHP included.
- Added the option "Minimum Reliability Level" to specify the minimum level of the reliability, as indicated by iHP, above which positions are executed.

Read the Comment I posted on May, 7th, 2015