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

 
Roman:

The help says that the timeframe value should be returned, not the identifier converted withEnumToString()
The _Period variable returns int.
ENUM_TIMEFRAMES Period() also implies int is returned.

You are the only one who implies it. Actually Period() returns the value of enum_TIMEFRAMES.

If you print out the values of constants in this enumeration, you will see numbers you are already familiar with.

And it's always been like this. It's been like this since the birth of MQL5.

And it's clearly written in the help what is returned:

Value can be one of values of enumeration ENUM_TIMEFRAMES.

Документация по MQL5: Проверка состояния / Period
Документация по MQL5: Проверка состояния / Period
  • www.mql5.com
Проверка состояния / Period - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin:

You are the only one who implies this. In fact, Period() returns the value of ENUM_TIMEFRAMES enumeration.

If you print out the values of constants in this enumeration, you will see numbers you are already familiar with.

And it's always been like this. It's been like this since the birth of MQL5.

And it's clearly written in the help what is returned:

What type do you think the ENUM enumeration returns?)
And the reference clearly states
Returns timeframe value of the current chart.

Print it on your own

Print(PERIOD_M30);
Print(PERIOD_H1);
 
Roman:

And the ENUM enumeration what type do you think it returns ?))
And the reference clearly says
Returns timeframe value of the current chart.

Print your own.

What do you want to prove to me?

I am perfectly aware of what is being printed and what data is being returned, when and where.

You want the number of minutes of the current period?

Get it this way:

PeriodSeconds(Period())/60;

or like this:

PeriodSeconds(PERIOD_CURRENT)/60;

Or like this:

PeriodSeconds()/60;
 
Artyom Trishkin:

What do you want to prove to me?

Nothing to you, I didn't write to you about the problem, I wrote to the developers.
Print more on M30, and on H1 and see the difference.

Print(_Period);
 
Roman:

You don't care, I didn't write to you about the problem, I wrote to the developers.
Print more on M30, and on H1 and see the difference.

It's not a problem. It never has been.

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

Artyom Trishkin, 2020.04.09 22:11

What do you want to prove?

I have a good understanding of what is printed and what data is returned, when and where.

You want the number of minutes of the current period?

get them this way:

PeriodSeconds(Period())/60;

or like this:

PeriodSeconds(PERIOD_CURRENT)/60;

or like this:

PeriodSeconds()/60;

 
Roman:

You don't have to, I didn't write about the problem to you, I wrote it to the developers.
Print more on M30 and H1 and see the difference.

Can't you get away from MQL4?

Do it in MQL4 like this:

PeriodSeconds(Period())/60;

or like this:

PeriodSeconds(PERIOD_CURRENT)/60;

Or like this:

PeriodSeconds()/60;

And print out the resulting values.

 
Artyom Trishkin:

Can't you get away from MQL4?

Do it in MQL4 like this:

or like this:

or like this:

and print out the resulting values.

I haven't used mql4 )) and I didn't get used to it.
Why do you have to divide by 60 more?
Where does it say that in the help?
It's already your crutches that bypass the bug.
Now check your crutch, on all timeframes

Print(_Period / 60);
 
Roman:

I haven't used mql4 )) and I didn't get used to it.
Why do you have to divide by 60 more?
Where does it say that in the help?
It's already your crutches that bypass the bug.

facepalm ...
 
Roman:

Variable _Period and Period() function up to and including M30, displays a value in minutes.
If period M1 then 1
If period M2 then 2
...
If period M30 then 30

It is logical that hourly period will be 60
two hour period 120
three hour 180
etc.

But from H1 onwards the wrong values are displayed.

if the program outputs "wrong values", you need to see what the program "thinks", but it can only think in binary format

I checked it, and it did:

void OnStart()
{

   ENUM_TIMEFRAMES allperiod[] = {PERIOD_CURRENT, PERIOD_M1, PERIOD_M2, PERIOD_M3, PERIOD_M4, PERIOD_M5, PERIOD_M6, PERIOD_M10, PERIOD_M12, PERIOD_M15, PERIOD_M20, PERIOD_M30, PERIOD_H1, PERIOD_H2,
                                  PERIOD_H3, PERIOD_H4, PERIOD_H6, PERIOD_H8, PERIOD_H12, PERIOD_D1, PERIOD_W1, PERIOD_MN1
                                 };
   for(int i = 0; i < ArraySize(allperiod); i++)
      Print(UintToBinary((uint)allperiod[i]));

}
//+------------------------------------------------------------------+
string UintToBinary(uint n)
{
   string r = "";
   if(n == 0) return("0");
   while(n != 0)
   {
      r = (n % 2 == 0 ? "0" : "1") + r;
      n /= 2;
   }
   return(r);
}
//+------------------------------------------------------------------

2020.04.10 00:38:57.118 tst (EURUSD,H1) 0

2020.04.10 00:38:57.118 tst (EURUSD,H1) 1

2020.04.10 00:38:57.118 tst (EURUSD,H1) 10

2020.04.10 00:38:57.118 tst (EURUSD,H1) 11

2020.04.10 00:38:57.118 tst (EURUSD,H1) 100

2020.04.10 00:38:57.118 tst (EURUSD,H1) 101

2020.04.10 00:38:57.118 tst (EURUSD,H1) 110

2020.04.10 00:38:57.118 tst (EURUSD,H1) 1010

2020.04.10 00:38:57.118 tst (EURUSD,H1) 1100

2020.04.10 00:38:57.118 tst (EURUSD,H1) 1111

2020.04.10 00:38:57.118 tst (EURUSD,H1) 10100

2020.04.10 00:38:57.118 tst (EURUSD,H1) 11110

2020.04.10 00:38:57.118 tst (EURUSD,H1) 10000000001

2020.04.10 00:38:57.118 tst (EURUSD,H1) 100000000000010

2020.04.10 00:38:57.118 tst (EURUSD,H1) 100000000000011

2020.04.10 00:38:57.118 tst (EURUSD,H1) 100000000000100

2020.04.10 00:38:57.118 tst (EURUSD,H1) 100000000000110

2020.04.10 00:38:57.118 tst (EURUSD,H1) 100000000001000

2020.04.10 00:38:57.118 tst (EURUSD,H1) 1000000001100

2020.04.10 00:38:57.118 tst (EURUSD,H1) 100000000011000

2020.04.10 00:38:57.118 tst (EURUSD,H1) 100000000001

2020.04.10 00:38:57.118 tst (EURUSD,H1) 1100000000000001


 
Artyom Trishkin:
facepalm ...

Really sleeve...

Print on different timeframes.

Print(_Period);
2020.04.09 23:39:49.963 VP (EPM20,M1)   1
2020.04.09 23:39:53.135 VP (EPM20,M3)   3
2020.04.09 23:39:53.758 VP (EPM20,M5)   5
2020.04.09 23:39:54.377 VP (EPM20,M10)  10
2020.04.09 23:39:55.094 VP (EPM20,M15)  15
2020.04.09 23:39:55.679 VP (EPM20,M30)  30
2020.04.09 23:39:56.384 VP (EPM20,H1)   16385  //Почему не 60 ?
2020.04.09 23:39:57.071 VP (EPM20,H4)   16388  //Почему не 240 ?
2020.04.09 23:39:57.641 VP (EPM20,D1)   16408  //Почему не 1440 ?
2020.04.09 23:39:58.181 VP (EPM20,W1)   32769  и т.д.
2020.04.09 23:39:58.768 VP (EPM20,MN1)  49153
Reason: