Discussion of article "Optimizing a strategy using balance graph and comparing results with "Balance + max Sharpe Ratio" criterion"

 

New article Optimizing a strategy using balance graph and comparing results with "Balance + max Sharpe Ratio" criterion has been published:

In this article, we consider yet another custom trading strategy optimization criterion based on the balance graph analysis. The linear regression is calculated using the function from the ALGLIB library.

MACD Sample balance regression.mq5, EURUSD, H4, no forward test

The following parameters are selected for optimization:

Pic. 19. Tester, Inputs tab

Pic. 19. Tester, Inputs tab

I will conduct the same three tests for MACD Sample balance regression EA:

  • Test 1: Optimizing the standard "Balance + max Sharp Ratio" parameter
  • Test 2: Optimizing the "Custom max" custom parameter, while the traded volumes optimization parameter is 'false'
  • Test 3: Optimizing the "Custom max" custom parameter, while the traded volumes optimization parameter is 'true'

Author: Vladimir Karputov

 

The article is interesting as an example of using standard libraries to achieve the goal. I have been using balance RMS analysis for more than two years on MT4 - it is a very useful method for Expert Advisors with position averaging.

Personally, the article lacks information about creating a custom report, i.e. writing the results of optimisation to a file, especially when optimising through agents.

 

There was a recent article (too lazy to look for it) that also used"linear regression". I gave a detailed comment on it, I will repeat it.

Both authors make identical mistakes: they confuse qualitatively different concepts of "linear regression" and "linear approximation". The former refers to random variables and the latter to deterministic ones. Their equations differ by the random variable, which is the error. I don't know how in Alglib, but in any normal statistical package the error accounting results in the EVALUATION of regression coefficients, as there is an error for them, which can be multiple of the nominal value of the calculated coefficient, which leads to a sad result: the value of the coefficient is calculated, we see it, but in reality it is not there, and we can't use what we see This circumstance is not taken into account in the article and for the terminology "linear regression" the article is absolutely wrong.


If we change the words "linear regression" to "linear approximation", which will correspond to the essence of the article, in which the balance is considered as a set of deterministic rather than random values, then it is quite an interesting and useful article.

 

Hey for some reason my file won't include the balanceregression. Any way to troubleshoot this? I have it saved in my files and under include. 


 
Scott David Maclean :

Hey for some reason my file won't include the balanceregression. Any way to troubleshoot this? I have it saved in my files and under include. 


1. Read the error description and check your paths.

2. If you have any mistake, please provide reproducible results: at least you need a complete code and at least you need proof of the presence of files in the specified folders.

 

have a general question : why when we are populating arrays of trade results, we only consider trades with positive balance impacts? i.e. why  arr_profits  is only filled with trades of (commission + swap + profit) > 0.0 ?

 aren't the dips in the balance curve (which are the results if loss of trades ) also affecting the LR line and hence the GetProfitStability?

 

I got some errors when I tried to compile BalanceRegression.mph:


The two commented out lines generated the following error - after digging around a bit, I found that the alglib library was updated.

The updated lines compile and the code runs, but I've never used CMatrixDouble before, so I'm not 100% sure that the fix is correct.


operator[] constant variable cannot be passed as reference


 CMatrixDouble xy(arr_size,2);
   for(int i=0;i<arr_size;i++)
     {
      //xy[i].Set(0,i+1);
      //xy[i].Set(1, arr_profits[i]);
      
      xy.Set(i, 0, i+1);
      xy.Set(i, 1, arr_profits[i]);


Also, the commented out line, in the same file, returned undefined variable - again, I think it was due to the alglib update:

//double TrendMSE=linear_report.m_rmserror;

double TrendMSE=linear_report.m_RMSError;