Creating random numbers in MQL4 - page 2

 
JC:

Time for my own geeky suggestion...

Another option is to generate a larger range of random numbers. For example, combining multiple calls to rand() in order to generate a 64-bit (ulong) number. The output % 5 then still has bias, but becomes reduced to infinitesimal proportions. Also provides an answer if you need a range of random numbers larger than 32768.

For the full geek effect, the following GetRandomNumber() will use Windows API calls if available, and only fall back to the above function if "Allow DLL imports" is turned off. Microsoft say that this is "far more random than the data generated by the typical random number generator such as the one shipped with your C compiler"; in other words, far more random than what MT4 will be using.

Thanks for sharing. Hope to have more geeky suggestions from you. ;)