Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1021

 
kashi_ann:

Good evening,


Somewhere I came across an article where all the code for a "test" EA was written/deciphered. I forgot to save it and I can't find it. Maybe someone knows, has seen this article?

Virtually every article has a test EA code in it. How can anyone know what you are asking about?

 
ToNy_Nazarov:

Afternoon!
Is it possible for an EA for MT4 to work with prices with 5 decimal places? If yes, how should I do it? I am working via Forex Club.

The Digits function return "5", but the Bid price returns "1.1094" instead of "1.10943", i.e. without the 5th sign.
How can I get the full price to work with the 5th decimal place?

Also, the Point function outputs a value of 0 instead of 0.00001. Why does this happen and how do I get the correct value?

Of course you can. By default.

No code, no answer.

 
How do I take a single digit out of a number? Let's say there is a number 1.2568. How do I take the last digit "8"? I can use DoubleToStr() to convert it to a string and then use StringSubstr() to get the last number and convert it to int. Any other options?
 
Yevhenii Levchenko:
How do I take a single digit out of a number? Let's say there is a number 1.2568. How do I take the last digit "8"? I can use DoubleToStr() to convert it to a string and then StringSubstr() to get the last number and convert it to int. Any other options?

There are always other options.

If it is a normalised value, it must be multiplied, in this case by 10000 or divided by 0.0001 to get the integer 12568 and takethe remainder of the division by 10.

12568%10=8

 
Alexey Viktorov:

There are always other options.

If it is a normalised value, it must be multiplied, in this case by 10000 or divided by 0.0001 to get the integer 12568 and take the remainder of the division by 10.

12568%10=8

Great option! Thank you Victor!
 
Yevhenii Levchenko:
Great option! Thank you, Victor!

When I was younger my name was Alexey. But I like Victor too:)))

 
Artyom Trishkin:

Of course you can. By default.

No code, no answer.


//--------------------------------------------------------------------
int start()
{
Comment("Bid = ", Bid,
"\nAsk = ", Ask,
"\nPoint = ", _Point,
"\nDigits = ", Digits);
return(0);
}
//--------------------------------------------------------------------
Files:
 
Alexey Viktorov:

When I was younger my name was Alexey. But I like Victor too :)))

Oops, something's gone wrong ))))

Sorry, Alexei)))

 
ToNy_Nazarov:

//--------------------------------------------------------------------
int start()
{
Comment("Bid = ", Bid,
"\nAsk = ", Ask,
"\nPoint = ", _Point,
"\nDigits = ", Digits);
return(0);
}
//--------------------------------------------------------------------

The DoubleToString() function is used to print out real numbers

Документация по MQL5: Преобразование данных / DoubleToString
Документация по MQL5: Преобразование данных / DoubleToString
  • www.mql5.com
[in]  Формат точности. Если значение digits лежит в диапазоне от 0 до 16, то будет получено строковое представление числа с указанным количество знаков после запятой. Если значение digits лежит в диапазоне от -1 до -16, то...
 
Artyom Trishkin:

The DoubleToString() function is used to print real numbers

The question is completely solved, thanks for the help!

//--------------------------------------------------------------------
int start()
{
double delta = Ask-Bid;
double delta2 = 1.10059-_Point;
Comment("Bid = ", DoubleToString(Bid,5),
"\nAsk = ", DoubleToString(Ask,5),
"\nDelta = ", DoubleToString(delta,5),
"\nDelta2 = ", DoubleToString(delta2,5),
"\nPoint = ", DoubleToString(_Point,5),
"\nDigits = ", Digits);
return(0);
}
//--------------------------------------------------------------------



Files: