[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 451

 
bernc:

I.e. you need this function F(8,5464.00) = 85464.00

8.5464/0.0001=85464
 
peshihod:

MathMod() is division. The rest is pure mathematics: if the result of TimeLocal() is divided by 20 every second (or more often), then every 20 seconds the remainder will be zero.

Conclusion: the same idea can be implemented in different ways.


Why do I have to do it every 20 seconds? Why not at 19 or 17?

bool flag = true;
int i=0;
int w=0;
double sum;

int t=20;

int start()
{
sum=TimeLocal() / t;

if (flag)
{
while(i<20)
{

w=w+1;
Alert(+w,"-й, Результат TimeLocal-",+sum);
i++;
sum=sum/20;
Sleep(1000);

}
flag = false;
}
return(0);
}

Here it equals zero every 11 seconds. Divided by 20, 20 times.

Sorry for the nubian questions, it's just something I want to understand .

 

Why do you divide by 20 times exactly?

You have to divide until you win ;)

 
peshihod:
8.5464/0.0001=85464

Thank you.

But that's not what I meant, the comma is the triad separator and the dot separates the fractional part.

I have a string 8,5464.00 I need to convert it to a number. StrToDouble(8,5464.00) takes 8.

F(8,5464.00) = 85464.00

 

try this function

{

search for a comma via https://docs.mql4.com/ru/strings/StringFind

Assembling a new string from two parts: a string before the comma and a string after the comma https://docs.mql4.com/ru/strings/StringGetChar

Convert to number StrToDouble()

}

 

Here's a prime example, just like you said.

Hmmm...

How does it happen that it turns exactly zero in 20 seconds . See the local time under the number 8000000000... What's the tricky part? Maybe I just need to take a break, eh....

int i=0;
int e;
int w=0;
int start()

{
while(true)
{
e=MathMod(TimeLocal(), 20);
w=w+1;
Alert(+w,"-й, Результат MathMod-",+e);


Sleep(1000); // Спим 1-ну секунду


return(0);
}

 
rlx:

try this function

{

search for a comma via https://docs.mql4.com/ru/strings/StringFind

Assembling a new string from two parts: a string before the comma and a string after the comma https://docs.mql4.com/ru/strings/StringGetChar

Convert to number StrToDouble()

}

Isn't there any other way or will this function take a long time to run.

 

If MathMod(EVERYTHING, 20) = 0, it means (if memory serves me correctly)

that EVERY NUMBER is divided by 20 without a remainder.

20 40 60 80 100 120 140 160 etc.

 
bernc:

Is there no other way or will this function take a long time.



I don't know how else to take the comma out of the string.

 
bernc:

Thank you.

But that's not what I meant by a comma separating the triads, and a dot separates the fractional parts.

I have a string 8,5464.00 I need to convert it to a number. StrToDouble(8,5464.00) will change to 8.

F(8,5464.00) = 85464.00



By character, through string functions, remove the comma, then StrToDouble().