This simple Testing Honest Predictor (THP)
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).
- 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 theMinimum 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;