mql4 multicore parallelization

 

Is there an mql4 command to parallelize execution of for loops (or do while, or anything else for that matter)?

Say i have a 6 core machine and I want to run 1 million histories in each core, and then combine the statistics afterwards. How do I go about specifying which core to run each for loop in?

Better yet, is there a way to run for loops in my GPU (CUDA)?

 

May be in MT18 :)

or in a DLL C++

 

G

MT4 isnt 'thread aware' so cannot parallel process in the style of say SQL Server

-BB-

 

So i think that what i'm hearing is that there's nothing built into the MT4 compiler do do this, but it may be possible to code an external DLL and call that from a compiled EX4?

I would have no idea how to even begin to code an external DLL. This is way above my level of expertise, and I barely have time to work on my EA as it is, so i doubt i'll find the time to study how to do this. Has anyone succesfully done this in the past and has or knows where to get a multithreaded DLL that will work with MT4?

 
interesting
 

I don't think it's as simple as using a single command to parallelize the for loop. For simple parallelization you would have to make sure there aren't dependencies between each loop. Then you would have to create some sort of mapping system so that you can break the data apart and bring it back together correctly. You might be able to find a library written in C or C++ that helps with the mapping and also with the communcication between the different processses. You could try searching for some variant of C++ and MPI (Message Passing Interface). I've gotten parallelization to work in Matlab with the aid of a set of libraries called pMatlab and MATLABMPI and even with the libraries it was not easy. This is not for the faint of heart but it is a worthwhile learning experience.

I'm not sure exactly what you're trying to do but you could try starting multiple instances of the MT4 platform and then create 6 separate mql4 robots that each run a portion of the data and run the robots at the same time. By doing this, the operating system should distribute the computation to the multiple cores. You could then create your own message passing interface by writing the results of each robot to a file and then you could have a master robot read the files and compile the results.

 

Bradstreet,

What I'm trying to do is parallelize a monte carlo algorithm. For nuclear engineering applications we run millions (or hundreds of million) of histories to get meaningful stats, and the same would be true of any monte carlo application. Each history is independent of each other, so it's a highly parallelizable process and the loops don't need to talk to each other. You then combine all the outcomes from each history and get meaningful stats. The idea of multiple instances and a common output file might work, although i was hoping for a cleaner, less disk-intensive and rube goldberg-esque approach.

 

"I would have no idea how to even begin to code an external DLL. "

There is a sample included with every copy of MT4.

 

Thanks for the tip. I'll look into it. Maybe it's not as daunting as i assumed.

Reason: