**lutade wrote**>>

This is a follow up to the recent article Be In-Phase by Mikhail Korolyuk. As my comments would be too extensive to add there and the topic is (as I think) of general interest, I decided to start a new thread here. This is to be seen also as a attempt to contribut something to the MQL4 community, as I am grateful for the software and all the articles and I would like to "give something back".

Mikhail Korolyuk writes in his article

"There is a whole group of methods that ... allow us on the basis of this analysis to filter some trades, the risk for which exceeds the limits determined by the trader. Applying filters on the basis of capital curve analysis allows us to reduce the trading risk. However, the reverse of this medal is decreasing in return of the system, because its trades have, all in all, a positive expected payoff, and the group of riskier trades selected using filters usually has a positive expected payoff, as well."

Maybe the folowing will be natural for the professional trader, but I hope for some of you this may be an unknown method.

Assume you have an EA, which gives you a reasonable number of trades with a reasonable profit. Most EAs will have some condition similar to the following, which is from the code of my sample EA:

A reasonable assumption is that the greater the difference between MA1 and MA2, the greater is the probability that the trade will make profit. In order to open only positions when there is a higher probability of winning, a filter could be applied:

This will increase the profit factor, but unfortunatelly will also decrease the number of trades and the overall profit, because the filtered trades would have been profitable too, on average:

The solution should be to use for the trades with a higher probability of winning a higher lotsize and for the trades with a smaller probability of winning a smaller lotsize. The code would be similar to the following:

The variable *Factor* should have a value between 0 and 1 and can be used as an extern variable for better optimization. For my sample EA I found the best results when using a value of Filter=2 and Factor between 0.4 and 0.5:

Note, that the best results with applied filter have less drawdown and more profit than the best unfiltered results (rows at the end of the list with Filter=0 or Factor=1). It is also possible to estimate the "best" Factor value by using the Kelly formula. From the filtered and unfiltered trades I get the following data:

Trades | PT | LT | %PT | GP | GL | AP | AL | PF | |
---|---|---|---|---|---|---|---|---|---|

Unfiltered | 167 | 109 | 58 | 65.27% | 37321 | 21697.9 | 342.39 | 374.10 | 1.72 |

"good" trades | 80 | 56 | 24 | 70.00% | 19665.8 | 8982.3 | 351.18 | 374.26 | 2.19 |

"bad" trades | 87 | 53 | 34 | 60.92% | 17665.2 | 12715.6 | 333.31 | 373.99 | 1.39 |

Using the data in my online simulator I get as optimal Lotsize-ratio 4.56:10.16 = 0.45:1, i.e. the Factor should be 0.45, which is in accordance with the result of the optimizer. Now due to the smaller lotsize the overall profit is reduced, however it is possible to increase the *Perc* -value for the lotsize calculation. Using the online simulator again (here with other parameters in the url string) gives an estimation that for the same risk the Perc value can be increased by (10.16-7.3)/7.3*100%=39.2%. The following table shows, that using the EA with filtered and lotsize-adjusted trades results in more profit with less drawdown:

Filter-Perc | Total net profit | Absolute DD | Maximal DD | Relative DD | PF |
---|---|---|---|---|---|

Unfiltered-5% | 11304.46 | 1184.44 | 14.14% | 14.14% | 1.83 |

Filtered-7% | 14283.60 | 455.37 | 6.53% | 10.42% | 2.00 |

Unfiltered-20% | 137998.93 | 4444.64 | 22.17% | 49.28% | 1.95 |

Filtered-24% | 152176.22 | 1894.80 | 21.20% | 32.56% | 2.04 |

Here is a picture of the balance curve from January 2008 until now when using the EA with filtered trades and Perc=7% (backtest):

The parameters of the sample EA had been optimized for the period from April 2008 until now (July). Later it was tested, if and how it works for the time before April, and as can be seen, it would have made small losses there. This is what I also expect for the future, when someday the parameters don't fit anymore to the market conditions. Then it is important, that the losses will be small, before the EA can be disabled or the parameters adjusted. The data here suggest, that the unavoidable losses will be smaller when using the filter method.

I hope I had something new for some of you fellow traders. Please excuse possible grammar or spelling errors, english is not my native language.

Can I get a Copy of the EA Please

JMB9922@yahoo.com

thanks

This is a follow up to the recent article Be In-Phase by Mikhail Korolyuk. As my comments would be too extensive to add there and the topic is (as I think) of general interest, I decided to start a new thread here. This is to be seen also as a attempt to contribut something to the MQL4 community, as I am grateful for the software and all the articles and I would like to "give something back".

Mikhail Korolyuk writes in his article

Maybe the folowing will be natural for the professional trader, but I hope for some of you this may be an unknown method.

Assume you have an EA, which gives you a reasonable number of trades with a reasonable profit. Most EAs will have some condition similar to the following, which is from the code of my sample EA:

A reasonable assumption is that the greater the difference between MA1 and MA2, the greater is the probability that the trade will make profit. In order to open only positions when there is a higher probability of winning, a filter could be applied:

This will increase the profit factor, but unfortunatelly will also decrease the number of trades and the overall profit, because the filtered trades would have been profitable too, on average:

The solution should be to use for the trades with a higher probability of winning a higher lotsize and for the trades with a smaller probability of winning a smaller lotsize. The code would be similar to the following:

The variable

Factorshould have a value between 0 and 1 and can be used as an extern variable for better optimization. For my sample EA I found the best results when using a value of Filter=2 and Factor between 0.4 and 0.5:Note, that the best results with applied filter have less drawdown and more profit than the best unfiltered results (rows at the end of the list with Filter=0 or Factor=1). It is also possible to estimate the "best" Factor value by using the Kelly formula. From the filtered and unfiltered trades I get the following data:

Using the data in my online simulator I get as optimal Lotsize-ratio 4.56:10.16 = 0.45:1, i.e. the Factor should be 0.45, which is in accordance with the result of the optimizer. Now due to the smaller lotsize the overall profit is reduced, however it is possible to increase the

Perc-value for the lotsize calculation. Using the online simulator again (here with other parameters in the url string) gives an estimation that for the same risk the Perc value can be increased by (10.16-7.3)/7.3*100%=39.2%. The following table shows, that using the EA with filtered and lotsize-adjusted trades results in more profit with less drawdown:Here is a picture of the balance curve from January 2008 until now when using the EA with filtered trades and Perc=7% (backtest):

The parameters of the sample EA had been optimized for the period from April 2008 until now (July). Later it was tested, if and how it works for the time before April, and as can be seen, it would have made small losses there. This is what I also expect for the future, when someday the parameters don't fit anymore to the market conditions. Then it is important, that the losses will be small, before the EA can be disabled or the parameters adjusted. The data here suggest, that the unavoidable losses will be smaller when using the filter method.

I hope I had something new for some of you fellow traders. Please excuse possible grammar or spelling errors, english is not my native language.