Page 1 of 1

Enhanced random number generator DLL

Posted: 12 Apr 2011
by furytrader
Some of my research recently has involved the use of random numbers. In conducting this research, I discovered that when I run an optimization scan using MultiCharts, the program has a tendency to duplicate random numbers across trials, so much so that I tended to see the same random number set appear twice during an optimization. This limited my ability to do research since I'd see every random number set twice.

To overcome this apparent shortcoming in MultiCharts, I wrote a small dll using FreeBasic that allows the user to generate a more robust random number integer by inputting the minimum and maximum values the integer could be. To use this function, the format is:

Code: Select all

value = RandomInteger(5,10)
This will generate a random integer between (you guessed it) 5 and 10. What's nice about this .dll is that it includes a randomize call every time it is asked to generate a random number that relies on the "Mersenne Twister", a method of generating very high quality pseudo-random numbers very quickly. In my experience in testing this function, I did not see duplicated random number sets at all, and there was no degradation in the speed of calculation.

In the attached .zip file, I have included the following files:

1) "randomint.dll" - this should be saved on the c:\ level of your hard drive (i.e., "c:\randomint.dll"

2) "RandomInteger.pla" - this includes the RandomInteger function written in EasyLanguage that references the .dll

3) "randomint.bas" - this is the Freebasic code for the .dll, for anyone interested in toying with it.

If anyone has any questions or suggestions, feel free to share here.

Re: Enhanced random number generator DLL

Posted: 12 Apr 2011
by TJ
Nice work.

Thanks for sharing.

Re: Enhanced random number generator DLL

Posted: 18 Apr 2011
by sptrader
Yes, very nice- here is a screen shot of a 2 to 20 random test.

Re: Enhanced random number generator DLL

Posted: 31 Dec 2016
by rezanp1356
hi,
can you help me on this,

i used the function in a signal but there was the error telling that it can not find randomint.dll.
I copied dll file to multicharts folder and change it a little bit;

external: "randomint.dll",int,"RandomInt", int,int;
Input: LowBound(numericSimple),HighBound(numericSimple);
RandomInteger = randomint(LowBound,HighBound);

,but the error is still there.

Re: Enhanced random number generator DLL

Posted: 06 Jan 2017
by sptrader
In the list of directions to follow, it says to put the .dll into the "root" directory of your "C" drive.. not sure if that will help but worth a shot.

** Upodate:

I just tried it myself and I get the same "cannot find dll" error, I suspect that this dll is very old and may be a 16bit dll, not sure if MC64 (the version that I use) can read them...

The .bas source code file is included with the randomintfiles.zip file so maybe someone could re-compile it into 32bit -64bit... I'm not a programmer, but I'll try to look at it over the weekend..

MC32bit "Might" be able to read it.