Generating uniformly distributed random numbers

 

Hello everybody,

I need help on how to generate uniformly distributed random numbers in MQL5. I know that for MQL4 there exists a function  mathinrangerandom that does this job, is there anythig equivalent for MQL5?

Fast Dive into MQL5
Fast Dive into MQL5
  • 2012.08.02
  • MetaQuotes Software Corp.
  • www.mql5.com
You have decided to study MQL5 trading strategies' programming language, but you know nothing about it? We have tried to examine MQL5 and MetaTrader 5 terminal from the newcomers' point of view and have written this short introductory article. In this article, you can find a brief idea of the possibilities of the language, as well as some tips on working with MetaEditor 5 and the terminal.
 
hardhu:

Hello everybody,

I need help on how to generate uniformly distributed random numbers in MQL5. I know that for MQL4 there exists a function  mathinrangerandom that does this job, is there anythig equivalent for MQL5?

You can use the mql4 code of MathInRangeRandom, it works exactly the same with mql5.
 
angevoyageur:
You can use the mql4 code of MathInRangeRandom, it works exactly the same with mql5.
Thanks a lot for your answer. Have you also any suggestion in the case the task is to generate random integer numbers in a specific range?
 
hardhu:
Thanks a lot for your answer. Have you also any suggestion in the case the task is to generate random integer numbers in a specific range?
Modify the MathInRangeRandom() function to return an integer.
Reason: