Random Numbers Below 1
If you had used this, you would have found this: MathRand between 3000 and 5000 - Forex Trading Tutorial - Expert Advisors and Automated Trading - MQL5 programming forum (two weeks ago) and RandomLinear (2019)
RandomLinear(30000)/300000.0+0.4; // [0.40000 … 0.4999966666666667] increments of 0.000003333 RandomLinear(10000)/100000.0+0.4; // [0.40000 … 0.49999] increments of 0.00001 RandomLinear(5000,4000)/10000; // [0.40000 … 0.49999] increments of 0.0001
MathRand() returns a pseudorandom integer within the range of 0 to 32767.
Number between 0.4 and 0.5 is:
double Number = 0.4 + MathRand() * (0.5 - 0.4) / 32767.;
If you had used this, you would have found this: MathRand between 3000 and 5000 - Forex Trading Tutorial - Expert Advisors and Automated Trading - MQL5 programming forum (two weeks ago) and RandomLinear (2019)
double Number = 0.4 + MathRand() * (0.5 - 0.4) / 32767.;
- Read the links I provided. Your code does not generate numbers of equal frequency. There is only a 1/32768 (.00003) chance of 0.5. There is a 3/32767 (.000091) chance of 0.4
- It also generates values between [0.4 and 0.5] inclusive. Inclusive was not specified, like a clock 0000…2400 does not include 2400.