Enhanced random number generator DLL

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
furytrader
Posts: 353
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 154 times
Been thanked: 215 times

Enhanced random number generator DLL

Postby furytrader » 12 Apr 2011

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.
Attachments
RandomIntFiles.zip
(5.07 KiB) Downloaded 189 times

User avatar
TJ
Posts: 6586
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1907 times

Re: Enhanced random number generator DLL

Postby TJ » 12 Apr 2011

Nice work.

Thanks for sharing.

sptrader
Posts: 638
Joined: 09 Apr 2010
Location: Colorado
Has thanked: 401 times
Been thanked: 238 times
Contact:

Re: Enhanced random number generator DLL

Postby sptrader » 18 Apr 2011

Yes, very nice- here is a screen shot of a 2 to 20 random test.
Attachments
Random Gen.png
Random Gen.png (14.2 KiB) Viewed 824 times

rezanp1356
Posts: 11
Joined: 03 Oct 2016
Has thanked: 5 times

Re: Enhanced random number generator DLL

Postby rezanp1356 » 31 Dec 2016

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.

sptrader
Posts: 638
Joined: 09 Apr 2010
Location: Colorado
Has thanked: 401 times
Been thanked: 238 times
Contact:

Re: Enhanced random number generator DLL

Postby sptrader » 06 Jan 2017

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.


Return to “User Contributed Studies and Indicator Library”