Errors, bugs, questions - page 81

 
Urain:

The call can be made with specifying the period, then the value of the specified TF will be returned,

or without indication of the period, the value will be returned from the current one

(r) :o)

I guess this is the way to do it, right?

double  Close(int i,ENUM_TIMEFRAMES tf=PERIOD_CURRENT){...
 
maryan.dirtyn:
int
right here at the top there is a function for transferring from MQL4 to MQL5 and you can transfer back...
 
maryan.dirtyn:
hallelujah... now that's a deal))))))
The timeframe value can be obtained in two ways using a predefined variable
int _Period

В переменной _Period хранится значение таймфрейма текущего графика.

and with the function

Period

Возвращает значение таймфрейма текущего графика.

ENUM_TIMEFRAMES  Period();
 

Возвращаемое значение

Содержимое переменной _Period, в которой хранится значение таймфрейма текущего графика. Значение может быть одним из значений перечисления ENUM_TIMEFRAMES.
 
maryan.dirtyn:

to make it work like this, it must still be like this, right?

No then overloading won't work, you won't be able to compile. My code is correct and the call in the next post is also correct.
 
Urain:
You can go from MQL4 to MQL5 and vice versa...

In order to find out the number of minutes of a given period of the graph, divide the value of thePeriodSeconds function by 60. This link shows a 404 error :) I will try it myself:

int PeriodMQL4()
  { switch(Period())
     {
      case PERIOD_CURRENT: return(0);
      case PERIOD_M1:     return(1);
      case PERIOD_M5:     return(5);
      case PERIOD_M15:    return(12);
      case PERIOD_M30:    return(30);
      case PERIOD_H1:     return(60);
      case PERIOD_H4:     return(240);
      case PERIOD_D1:     return(1440);
      case PERIOD_W1:     return(10080);
      case PERIOD_MN1:    return(43200);      
      default: return(0);
     }
  }

Will this do? it won't))) so many errors it's scary)

 
Urain:
No then overloading won't work, you won't be able to compile. My code is correct and the call in the next post is also correct.
When inserting a function without explicit timeframe designation, i.e. just Close(0) ... doesn't compile), I have to manually set Close(0,PERIOD_CURRENT) ... but it's nothing )
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков - Документация по MQL5
 
maryan.dirtyn:
int

Ahhhh I remember it's simpler, but then you have to divide it by 60 to get the minutes.

Возвращает количество секунд в периоде.

int  PeriodSeconds(ENUM_TIMEFRAMES  period=PERIOD_CURRENT ); // период графика



int Per=PeriodSeconds(PERIOD_D1)/60;
Print("Period=",Per);
 
Urain:

Ahhhh I remember it's simpler, but then you have to divide by 60 to get the minutes.

Oh thank you)) May the force be with you)
 

A bit for working with periods as in MQL4

//Fumction MinuteToPeriod
ENUM_TIMEFRAMES MinuteToPeriod(int Value)
//Преобразовывает число сикунд в период, возвращаемый как ENUM_TIMEFRAMES
{
//----------------------------------------------------------------------------//
//Work variables / Служебные переменные
ENUM_TIMEFRAMES Result;
//----------------------------------------------------------------------------//
  switch(Value)
  {
  //Перирд текущещего графика
  case   0: return(PERIOD_CURRENT); break;
  //Минуты
  case   1: return(PERIOD_M1);  break;   //1 минута
  case   2: return(PERIOD_M2);  break;   //2 минуты
  case   3: return(PERIOD_M3);  break;   //3 минуты
  case   4: return(PERIOD_M4);  break;   //4 минуты
  case   5: return(PERIOD_M5);  break;   //5 минуты
  case   6: return(PERIOD_M6);  break;   //6 минуты
  case  10: return(PERIOD_M10); break;   //10 минуты
  case  12: return(PERIOD_M12); break;   //12 минуты
  case  15: return(PERIOD_M15); break;   //15 минуты
  case  20: return(PERIOD_M20); break;   //20 минуты
  case  30: return(PERIOD_M30); break;   //30 минуты
  //Часы
  case  60: return(PERIOD_H1); break;    //60 минут  - 1 час
  case 120: return(PERIOD_H2); break;    //120 минут - 2 часа  
  case 180: return(PERIOD_H3); break;    //180 минут - 3 часа
  case 240: return(PERIOD_H4); break;    //240 минут - 4 часа
  case 360: return(PERIOD_H6); break;    //360 минут - 6 часов
  case 480: return(PERIOD_H8); break;    //480 минут - 8 часов
  case 720: return(PERIOD_H12); break;   //720 минут - 12 часов
  //Старшие ТФ
  case 1440: return(PERIOD_D1); break;   //1 день
  case 10080: return(PERIOD_W1); break;  //1 неделя 
  case 43200: return(PERIOD_MN1); break; //1 месяц 
  //Default
  default: return(PERIOD_CURRENT);
  }
//----------------------------------------------------------------------------//
return(Result);
//----------------------------------------------------------------------------//
}

//Fumction PeriodToMinute
int PeriodToMinute(ENUM_TIMEFRAMES Value)
//Возвращает число секунд в периоде
{
//----------------------------------------------------------------------------//
//Work variables / Служебные переменные
int Result;
//----------------------------------------------------------------------------//
Result = PeriodSeconds(Value)/60;
//----------------------------------------------------------------------------//
return(Result);
//----------------------------------------------------------------------------//
}
 

I'm putting in a test from 2010.01.01 to today. I output the date of the very first bar 2009.01.02.

How can I make the first available bar be e.g. 2006.01.02?