Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1109

 
Vitaly Muzichenko:

Then I won't get a fractional number.

You probably need something like that:

typename(TralingStop)=="double" ? ...

 
Artyom Trishkin:

typename(TralingStop)=="double" ?

Not exactly, if you entered "input" in the input parameters, for example 15 or 15.0, then display just 15 in the input field, i.e. an integer. If you entered 12.3 in the input parameters, display 12.3 in the input field

 
Vitaly Muzichenko:

Not exactly, if you entered "input" in the input parameters, for example 15 or 15.0, then display just 15 in the input field, i.e. an integer. If you entered 12.3 in the input parameters, display 12.3 in the input field.

Well then it's a matter of determining the number of decimal places of any number. There was a topic like this somewhere - it was discussed there.

 
Artyom Trishkin:

Well then it's about determining the number of decimal places of any number. There was a topic like this somewhere - it was discussed there.

I think there was one, but I couldn't find it, so I wrote it here (

 
Vitaly Muzichenko:

Not exactly, if you entered "input" in the input parameters, for example 15 or 15.0, then display just 15 in the input field, i.e. an integer. If you entered 12.3 in the input parameters, then the input field should display 12.3.

Experiment with a script like this:

#property script_show_inputs
input double inp1 = 15.0;
input double inp2 = 12.3;
//+------------------------------------------------------------------+
void OnStart()
  {
   int dig1 = GetDigitsInDouble(inp1);
   int dig2 = GetDigitsInDouble(inp2);
   printf("inp1 = %f --> %s",inp1,DoubleToString(inp1,dig1));
   printf("inp2 = %f --> %s",inp2,DoubleToString(inp2,dig2));
  }
//_______________________________________________________________________
int      GetDigitsInDouble(double doublevalue)
  {
   long l=long(doublevalue/0.0000001);int result=0,i=10000000; while(result<7 && l%i>0)
     {i/=10; result++;}return result;
  }

2019.08.06 22:40:44.668 tst1 (EURUSD,H1) inp1 = 15.000000 --> 15

2019.08.06 22:40:44.668 tst1 (EURUSD,H1) inp2 = 12.300000 --> 12.3


it seems the 7th decimal place will sometimes be wrong

 
Vitaly Muzichenko:

It seems to have been, but I couldn't find it, so I wrote here (

Получаем количество десятичных знаков после запятой любых чисел (не только котировок) в обход Digits() на MQL4 и MQL5
Получаем количество десятичных знаков после запятой любых чисел (не только котировок) в обход Digits() на MQL4 и MQL5
  • 2018.11.03
  • www.mql5.com
Думаю не у одного меня была редкая ситуация когда нужно было получить количество десятичных знаков после запятой, а функция Digits() работает тольк...
 
Igor Makanu:

experiment with a script like this:

2019.08.06 22:40:44.668 tst1 (EURUSD,H1) inp1 = 15.000000 --> 15

2019.08.06 22:40:44.668 tst1 (EURUSD,H1) inp2 = 12.300000 --> 12.3


I think the 7th decimal place will be wrong sometimes

Artyom Trishkin:

Thank you all, I will try it!

 
How can I record information about an open position (lot, type) so that it can be read from an EA in another MT5 terminal?
 
Guys, can you explain this question, if there is optimization on remote agents and EA writes data to a file, then I understand that I won't get this data, because only my local agents are in the tester folder, and there are no remote ones...
Or am I looking in the wrong place?
if so, is there any way to implement the possibility of getting files from remote agents?
 
Vitaly Muzichenko:

I think there was one, but I couldn't find it, so I posted it here (

That's how it's described in the documentation. In fmod you put divisor 1 and get fractional part of number or 0. You don't care how many decimal places are entered in field or input variable.

Документация по MQL5: Математические функции / MathMod
Документация по MQL5: Математические функции / MathMod
  • www.mql5.com
Функция MathMod рассчитывает вещественный остаток f от val / y таким образом, что val = i * y + f , где i является целым числом, f имеет тот же знак, что и val, и абсолютное значение f меньше, чем абсолютное значение y.