Discussion of article "R-squared as an estimation of quality of the strategy balance curve"

 

New article R-squared as an estimation of quality of the strategy balance curve has been published:

This article describes the construction of the custom optimization criterion R-squared. This criterion can be used to estimate the quality of a strategy's balance curve and to select the most smoothly growing and stable strategies. The work discusses the principles of its construction and statistical methods used in estimation of properties and quality of this metric.

Linear regression is a linear dependence of one variable y from another independent variable x, expressed by the formula y = ax+b. In this formula, а is the multiplier, b is the bias coefficient. In reality, there may be several independent variables, and such model is called a multiple linear regression model. However, we will consider only the simplest case. 

Linear dependence can be visualized in the form of a simple graph. Take the daily EURUSD chart from 2017.06.21 to 2017.09.21. This segment is not selected by chance: during this period, a moderate ascending trend was observed on this currency pair. This is how it looks in MetaTrader:

Fig. 11. Dynamics of the EURUSD price from 21.06.2017 to 21.08.2017, daily timeframe

Author: Vasiliy Sokolov

 

Great article. Thank you for posting this.

 
MetaQuotes Software Corp.:

New article R-squared as an estimation of quality of the strategy balance curve has been published:

Author: Vasiliy Sokolov

The correlation coefficient of the equity curve is an awesome metric, I've used in another platform but I did not have the know how to develop in mql5.

I was looking for it for years!Great writing Vasiliy Sokolov,  Thank you soo much!

Vinicius from Brazil


 
Once again a high level article from the author.
Thank you
 

Thanks for the great article. 

In the article it is said that one of the drawbacks of R2 method is that it is "Applicable exclusively for estimation of linear processes or systems trading with a fixed lot". I'm trying optimize my strategy for the stock market and I use dynamic position volume based on the ATR value, so I guess I could not use this method in my case. But my question is how one could optimize a non linear system?

 
Normalize the volume : Take the profit and divide by the lot size
 
That is genius. Thanks alot for the great article! I wonder how R2 measuring quality compares to measuring standard deviation from an account balance moving average.
 

Hi,

if I try to use R²:

#include <Rsquare.mqh>
.
.
.
double OnTester()
{
   return CustomR2Balance();
}

Is okay.

but with

#include <Rsquare.mqh>
.
.
.
double OnTester()
{
   Manager.SetCustomOptimizeR2Balance(CORR_PEARSON);
   return Manager.OnTester();
}

I get:

'Manager' - undeclared identifier

How can I declare it in my EA?


How should I declare Manager in my EA

 

There's a lot of info here explaining the reasoning and your code, and I appreciate that. Here's the Tl;dr version for those of us for whom most of this went over our heads:

1. Add the includes

#include <Expert\Strategy\TimeSeries.mqh>
#include <Expert\Strategy\Strategy.mqh>

2. And the OnTester:

double OnTester()
{
   return CustomR2Balance();
}

That's it to implement it based on balance.

If your EA uses CStrategy (as the wizard EAs do), then add the same includes, and you can switch to the equity like this:

double OnTester()
{
   Manager.SetCustomOptimizeR2Balance(CORR_PEARSON);
   return Manager.OnTester();
}

What I have NOT figured out yet, and am hoping someone can help me with, is what to do to implement the equity listener in your own EA that's not based on CStrategy. All the article says is:

When it is necessary to calculate the strategy equity, however, users who do not employ CStrategy will have to do it themselves.

And I'm at a complete loss how to do that.
Reason: