void RandomTime(double mean_time, double max_time)
//exponential probability distribution 默认 均值4秒,最大25秒
{
if (IsTesting()) return; // return immediately if backtesting.
double tenths = MathCeil(mean_time / 0.1);//4-->40
if (tenths <= 0) return;
int maxtenths = MathRound(max_time/0.1); //25-->250
double p = 1.0 - 1.0 / tenths; //0.975
for(int i=0; i < maxtenths; i++)
{
if (MathRand() > p*32768) // MathRand() returns in 0..32767
break;
Sleep(100);
}
}
微信公众号:天泓评测
发表评论