R-Portfolio - a diversification method - page 7

 
Reshetov:

In MQL5, and even more so in MQL4 the code speed for such algorithms is too low, ie nothing good can be obtained in pure MQL, and at least a DLL has to be created. And it wouldn't make any sense anyway since portfolios don't need to be optimized in real time on every tick or on the bars of small timeframes.

Yuri, that's not true, mql5 is not inferior to toad in terms of speed.

As for the purpose of using it, for example, with respect to forex, I'm more interested in optimizing portfolios of strategies, not tools. So... excuses are not accepted. :)

But the good news is I can keep you company while writing code in mql5. I can even write it myself. Preferably just a description of the algorithm.

I think it will be fun.

 
MetaDriver:

Yuri, that is not true, mql5 is in no way inferior to toad in terms of speed.

You tell these fairy tales to your children. Java virtual machines do JIT compilation, i.e. they compile Java code into machine code before running the program. So the execution of Java applications is done in machine code.

See results comparing Quake2 performance in Java and C++: http://www.bytonic.de/html/benchmarks.html

Here's more on this topic: C#, C++, Java, Delphi benchmarks

After all, it's easy to check this by running the same benchmark written in Java and in MQL5.


MetaDriver:

As for the reason of using it - for example with respect to forex I'm more interested in optimizing strategy portfolios, not tools. So... Excuses are not accepted. :)

Well, then upload the first Equity differences of strategies to CSV file and optimize them. Why do you need excuses that MQL5 can supposedly "outrun" an application executed in machine code?

MetaDriver:

But the good news is, I can keep you company while writing code in mql5. I can even write it myself. Preferably just a description of the algorithm.


Go ahead. The Brown-Robinson algorithm is not a secret. Here is the code in Java:

  private int[] optimization(double[][] a) {
    Random rand = new Random();
    int m = a.length;
    int n = a[0].length;
    int[] p = new int[m];
    Arrays.fill(p, 0);
    int[] q = new int[n];
    Arrays.fill(q, 0);
    double[] x = new double[m];
    Arrays.fill(x, 0 d);
    double[] y = new double[n];
    Arrays.fill(y, 0 d);
    int r = rand.nextInt(m);
    int c = 0;
    for (int t = 0; t < 10000000; t++) {
        for (int j = 0; j < n; j++) {
          y[j] = y[j] + a[r][j];
        }
        c = 0;
        for (int j = 1; j < n; j++) {
          if ((y[j] == y[c]) && rand.nextBoolean()) {
            c = j;
          }
          if (y[j] > y[c]) {
            c = j;
          }
        }
        q[c] = q[c] + 1;
        for (int i = 0; i < m; i++) {
            x[i] = x[i] + a[i][c];
        }
        r = 0;
        for (int i = 1; i < m; i++) {
          if ((x[i] == x[r]) && rand.nextBoolean()) {
            r = i;
          }
          if (x[i] < x[r]) {
            r = i;
          }
        }
        p[r] = p[r] + 1;
    }

    return q;
  }
 
Reshetov:

You tell these fairy tales to your children. Java virtual machines do JIT compilation, i.e. they compile Java code into machine code before running the program. So the execution of Java applications is done in machine code.

Yura, this seems to be news to you, however the mql5 virtual machine works in a similar way. The compiler does the bytecode, before running it is precompiled into a nativ. It is the same as in java and sharp. You should read the mql5 forum more often.

See results comparing Quake2 performance in Java and C++: http://www.bytonic.de/html/benchmarks.html

Here's more on this topic: C#, C++, Java, Delphi benchmarks

It's easy to check it by running the same benchmark written in Java and in MQL5.

I have checked it. Although I've compared it not with java but with sharp. I got the same speed. I don't think that Java is at least 30-40% faster than Sharp. If there is a difference, it's not yet known in whose favor. I agree to compare with java as well. Which code would you recommend for comparative testing?

Well, then dump the first differences of Equity strategies into a CSV file and optimize it.

I'm not interested in such a variant. I want an embedded code. And I will.

Why do you need excuses that MQL5 can supposedly "outrun" an application, running in machine code?

See above. I don't count on overtaking, I count on being identical (plus or minus 10%).

Go ahead. The Brown-Robinson algorithm is not a secret. Here is the code in Java:

Yes, I have that code. You already posted it. I couldn't understand it right away. I was counting on comments at least, to really figure it out, not to just mess around.

Okay, I'll try again. There are descriptions of the algorithm idea on the Internet. I will figure it out.

 
MetaDriver:

Yura, this seems to be news to you, however the mql5 virtual machine works similarly. The compiler makes bytecode, before launching it is precompiled into a nativ. It is the same as in java and sharp. You should read the mql5 forum more often.

I have checked it. Although I've compared it not with java but with sharp. I got the same speed. I don't think that Java is at least 30-40% faster than Sharp. If there is a difference, it's not yet known in whose favor. I agree to compare with java as well. Which code would you recommend for comparative testing?

I'm not interested in such a variant. I want an embedded code. And I will.

See above. I don't reckon on overtaking, I reckon on being identical (plus or minus 10%).

Yes, I have that code. You already posted it. I couldn't understand it right away. I was counting on comments at least, to really figure it out, not to just mess around.

Okay, I'll try again. There are descriptions of the algorithm idea on the Internet. I will figure it out.

hilarious...

however

;)

 
MetaDriver:

Yes, I have that code. You already posted it. I couldn't get into it right away. I was at least hoping for a comment so I could really figure it out, not just mess around.

Okay, I'll try again. There are descriptions of the algorithm idea on the Internet. I'll figure it out.

There is nothing complicated about the code. I pass in arguments a payment matrix - a[][], in the output the optimal strategy of the player by columns of the payment matrix - q


Random rand = new Random(); // Объект rand - генератор случайных чисел
int[] q = new int[n]; //  Объявление целочисленного массива q  размером n и выделение под него памяти
int m = a.length; // переменной m присваивается значение в виде количества строк в платежной матрице
int n = a[0].length; // переменной n присваивается значение в виде количества столбцов в платежной матрице
Arrays.fill(p, 0); // Массив p инициализируется нулевыми значениями

int r = rand.nextInt(m); // значению переменной r присваивается случайное число в диапазоне от 0 до m - 1
rand.nextBoolean() // с вероятностью 50% / 50% даст случайным образом значение true или false
Everything else, any programmer who knows C similar languages will understand without any help. The only difference between Java and C is that there is no need to free memory. That is, if a variable is declared inside a curly bracket block {}, this means that after the block is closed, the variable outside the block is invalid and the Java virtual machine will independently free the memory that was allocated for it. If an attempt is made to refer to a variable declared inside a block outside of this block, the Java compiler will generate an error.
 
Alex5757000:
Why don't you write it all in mql5 and post the sources?

The source code is publicly available at http://r-portfolio.sourceforge.net/

If you need them, you can rewrite them in any programming language or contact Job - they do various whims and lusts of those who need to implement something in MQL code.

 
Yuri, I have a question about forming a portfolio with your programme. I asked it in the "Correlation Expert Advisor" thread, but I found this thread and will ask it here. You include gold in the portfolio along with the majors, but currency pairs and gold have different tick prices. How is this corrected in the calculation and which pairs do you use for your portfolio? I am interested in this topic and would like to know from an experienced specialist the approximate results of using the system.
 
FION:
Yuri, I have a question about forming a portfolio with your programme. I asked it in the "Correlation Expert Advisor" thread, but I found this thread and will ask it here. You include gold in the portfolio along with the majors, but currency pairs and gold have different tick prices. How is this corrected in the calculation and which pairs do you use for your portfolio? I am interested in this topic and would like to know from an experienced specialist the approximate results of using the system.
See reply to the correlation advisor
 
Reshetov:

Java virtual machines perform JIT compilation, i.e. compile Java code into machine code before running the program. So the execution of Java applications is done in machine code.


jit in java compiles to machine code in parts. As far as I understand it, mql5 compiles the whole program to machine code at once - this is more aot than jit.
 
Reshetov:
See answer to the correlation advisor

.

http://sourceforge.net/projects/r-portfolio/ - is it available in Russian ?