Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
How about random text?What code for it?
Example I have 20 text,and i want it appear randomly?
Could you assign each text string an integer associated with it?
such as:
PHP Code:
double Rnd = 20 + (0-20)*MathRand()/32767;
if (Rnd == 1) {Comment(" Text comment #1");}
if (Rnd == 2) {Comment(" Text comment #2");}
if (Rnd == 3) {Comment(" Text comment #3");}
if (Rnd == 4) {Comment(" Text comment #4");}
if (Rnd == 5) {Comment(" Text comment #5");}
if (Rnd == 6) {Comment(" Text comment #6");}
if (Rnd == 7) {Comment(" Text comment #7");}
if (Rnd == 8) {Comment(" Text comment #8");}
if (Rnd == 9) {Comment(" Text comment #9");}
if (Rnd == 10) {Comment(" Text comment #10");}
if (Rnd == 11) {Comment(" Text comment #11");}
if (Rnd == 12) {Comment(" Text comment #12");}
if (Rnd == 13) {Comment(" Text comment #13");}
if (Rnd == 14) {Comment(" Text comment #14");}
if (Rnd == 15) {Comment(" Text comment #15");}
if (Rnd == 16) {Comment(" Text comment #16");}
if (Rnd == 17) {Comment(" Text comment #17");}
if (Rnd == 18) {Comment(" Text comment #18");}
if (Rnd == 19) {Comment(" Text comment #19");}
if (Rnd == 20) {Comment(" Text comment #20");}
I just appear the Number from 1 to 20,the text still not appear?
Why it happen?
To understand what we are doing :
MathRand() returns an integer between 0 and 32767, so
MathRand()/32767 is a double between 0 and 1
If we multiply this double by 20, we get a double between 0 and 20
If we need an integer, for example to index an array, we need to round it, but we cannot use MathRound() because the boundaries 0 and 20 will have only half of the probability to be hit than the other integer values.
So we can use MathFloor(), but then 20 will never be it, and thus we have to use 21 as upper boundary.
There is still one problem remaining: if MathRand() returns exactly 32767, then the result will be 21, and we don't want this. So instead of 21 we have to use a slighly smaller number like 20.999999.
The final code may be:
PHP Code:
string Text[21] = {"I love papa", "I love mama", "I love my girlfriend", ...};
double Rnd;
int Index; // 0 to 20 : 21 values
Rnd = 20.999999*MathRand()/32767.0;
Index = MathFloor(Rnd);
I love papa", "I love mama", "I love my girlfriend """"" - you mean - rendom?
---------------
also example : MathRand as in Mladen's UniqueName generator
string MakeUniqueName(string first, string rest)
{
string result = first+(MathRand()%1001)+rest;
while (WindowFind(result)> 0)
result = first+(MathRand()%1001)+rest;
return(result);