

APeng: Hello! I am running an EA that puts every hour an order wiht random direction and close it one hour later again. I want to run it 1000 times to show that the results are normal distributed. before MathRand(), I get 1000 times the same testing results as MathRand() is always seeded in the same way. Right? Now I am running the optimization without MathSRand(TimeCurrent()) and the results seem do be different. I just need to know if I am right as I do not exactly know how the random function is working. Thanks! 1) TimeCurrent() is the brokertime in backtesting and MathRand() is placed in init() it should be always the same, but if this is intended to be sure try to use: MathSrand(1);? 2) If this is not intended follow the recommendation of mt4's reference: MathSrand(GetTickCount()); (or at least TimeLocal()) 3) To have a random 0 or 1 simply use MathRand()%2  this is either 0 or 1. 

gooly: 1) TimeCurrent() is the brokertime in backtesting and MathRand() is placed in init() it should be always the same, but if this is intended to be sure try to use: MathSrand(1);? 2) If this is not intended follow the recommendation of mt4's reference: MathSrand(GetTickCount()); (or at least TimeLocal()) 3) To have a random 0 or 1 simply use MathRand()%2  this is either 0 or 1. 1) + 2) lead to the same result for every test run in the optimization process. That makes sense as the seed is always the same and so all trade runs are the same. What seems to work is to use MathSrand(run) ; where run is the opimized parameter. If the optimization is done a second time, run has to be multiplied with an integer value or the random values in the second optimization process are the same like in the first. 3) thanks 

APeng: 1) + 2) lead to the same result for every test run in the optimization process. That makes sense as the seed is always the same and so all trade runs are the same. What seems to work is to use MathSrand(run) ; where run is the opimized parameter. If the optimization is done a second time, run has to be multiplied with an integer value or the random values in the second optimization process are the same like in the first. 3) thanks 1) + 2) I think in this case the (local) time variables are set at testbegin. I might be good for other reasons but not for rand number  I think. So for a randseed one has to use a real Windowsfunction: "kernel32.dll" has a timefunction: to use this look here https://www.mql5.com/en/forum/45792. May be just use the milliseconds? 
Hello!
I am running an EA that puts every hour an order wiht random direction and close it one hour later again. I want to run it 1000 times to show that the results are normal distributed.
When I usebefore MathRand(), I get 1000 times the same testing results as MathRand() is always seeded in the same way. Right?
Now I am running the optimization without MathSRand(TimeCurrent()) and the results seem do be different. I just need to know if I am right as I do not exactly know how the random function is working.
Thanks!