Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1171

 
Hello fellow programmers! Please help me. MQL5 has _Digits variable storing the number of decimals after the decimal point. I wonder if there is a variable storing the number of decimals before the decimal point. If it's an integer, I also need the number of decimals it consists of. For example, if the price is 23292, I need to get the figure 5 or if the price is 232920.12, I need to get the figure 6. If there is no such variable, how do I calculate the number of decimals before the decimal point?
 
Kolya32:
how do I calculate the number of digits before the decimal point?

roughly like this:

void OnStart()
{
   double v = 0.12345;
   for(int i = 0; i < 10; i++) {
      Print("v = ", v, " , dig = ", GetDigitsIntVal(v));
      v *= 10.0;
   }

}
//+------------------------------------------------------------------+
int GetDigitsIntVal(const double value)
{
   int result = 0;
   long dig = (long)fabs(floor(value));
   while(dig > 0) {
      result++;
      dig /= 10;
   }
   return(result);
}
//+------------------------------------------------------------------+

2020.01.05 08:17:42.135 tst_dig (EURUSD,H1) v = 0.12345 , dig = 0

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 1.2345 , dig = 1

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 12.345 , dig = 2

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 123.45 , dig = 3

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 1234.5 , dig = 4

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 12345.0 , dig = 5

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 123450.0 , dig = 6

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 1234500.0 , dig = 7

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 12345000.0 , dig = 8

2020.01.05 08:17:42.136 tst_dig (EURUSD,H1) v = 123450000.0 , dig = 9

 
What is the difference between mq5 and mqh files?
 
Igor Makanu:

like this:

void OnStart()
{
   double v = 0.12345;
   for(int i = 0; i < 10; i++) {
      Print("v = ", v, " , dig = ", GetDigitsIntVal(v));
      v *= 10.0;
   }

}
//+------------------------------------------------------------------+
int GetDigitsIntVal(const double value)
{
   int result = 0;
   long dig = (long)fabs(floor(value));
   while(dig > 0) {
      result++;
      dig /= 10;
   }
   return(result);
}
//+------------------------------------------------------------------+

Thank you very much, I'll look into it...

 

Why does the first synthetic work normally but the second one has an endless wait?
All quotes are loaded


audcad-audchf eurjpy-eurusd

 

Can you tell me how to create a synthetic? How do I make more bars?


 
Kolya32:
Hello fellow programmers! Please help me. In MQL5, there is a variable _Digits that stores the number of decimals after the decimal point. I wonder if there is a variable storing the number of decimals before the decimal point. Say, if the price is 23292, I need to get 5 or if the price is 232920.12, I need to get 6. If there is no such variable, how do I calculate the number of decimals before the decimal point?
Logarithms will save the day. Read the algebra textbook for... Shit, sclerosis, what grade is it, who remembers?
And no kidding, (int)MathMax(MathCell(MathLog10(price)),0.0)
 
Vladimir Simakov:
Logarithms will save the day. Read the algebra textbook for... Shit, sclerosis, what grade is it, who remembers?
And no kidding, (int)MathMax(MathCell(MathLog10(price)),0.0)

I haven't studied it in school yet, I think that in 8th grade there will be logarithms ))))

for sabotage, he kinda needs to decompose the price into integer and decimal places and count the number of digits before the decimal point, i doubt there is such a trading tool more than 18 digits (long is my example) before the decimal point

 

The forum is huge and there is no topic on the use of neural networks in trading. That's odd. Or is there somewhere?

Or is there just no one dealing with it?

 
Evgeny Dyuka:

The forum is huge and there is no topic on the use of neural networks in trading. That's odd. Or is there somewhere?

Or is there just no one dealing with it?

https://www.mql5.com/ru/forum/86386

Машинное обучение в трейдинге: теория и практика (торговля и не только)
Машинное обучение в трейдинге: теория и практика (торговля и не только)
  • 2016.05.26
  • www.mql5.com
Добрый день всем, Знаю, что есть на форуме энтузиасты machine learning и статистики...
Reason: