How could one generate large random numbers, ranging between 0 and X where X can be up to 1.500.000?
The standard random numbers generators I found are going up to 32767, not higher. And I need higher.
Among many other approaches, see https://www.mql5.com/en/forum/216865#comment_5866478
How could one generate large random numbers, ranging between 0 and X where X can be up to 1.500.000?
The standard random numbers generators I found are going up to 32767, not higher. And I need higher.
For a simple way to generate pseudo-random numbers you can use this :
int m_w = 521288629; int m_z = 362436069; void SetSeed(int z=0, int w=0) { if (z != 0) m_z = z; if (w != 0) m_w = w; } double GetRand() { m_z = 36969 * (m_z & 65535) + (m_z >> 16); m_w = 18000 * (m_w & 65535) + (m_w >> 16); return ((m_z << 16) + m_w + 1.0); }
Make sure to call the SetSeed() from somewhere (from init is good) - something like this :
SetSeed(TimeLocal(),TimeLocal()*TimeCurrent());
How could one generate large random numbers, ranging between 0 and X where X can be up to 1.500.000?
The standard random numbers generators I found are going up to 32767, not higher. And I need higher.
Multiply it by 45,777764213995788445692312387463.
Multiply it by 45,777764213995788445692312387463.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How could one generate large random numbers, ranging between 0 and X where X can be up to 1.500.000?
The standard random numbers generators I found are going up to 32767, not higher. And I need higher.