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

 
Alexey Kozitsyn:
Through a file, for example...

if you don't mind, a little more detail.

 
виталик:

if you don't mind, a little more detail.

To pull quotes, use the Copy functions:

https://www.mql5.com/ru/docs/series

Then https://www.mql5.com/ru/docs/files is a link to file operations.

Документация по MQL5: Файловые операции
Документация по MQL5: Файловые операции
  • www.mql5.com
Файловые операции - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Good evening, I'm making a "rails" pattern, but I can't get it to work.... can you see what's wrong? Thanks in advance.
Files:
jzogyr2.mq4  6 kb
 
sviter-pro:
Good evening, I'm making a "rails" pattern, but I can't get it to work.... can you see what's wrong? Thanks in advance.

int OnInit()
  {

   SetIndexBuffer(0,BuyTrain); SetIndexStyle(0,DRAW_ARROW,EMPTY,RazmerStrelok,coloru); SetIndexArrow(0,159); SetIndexEmptyValue(0,EMPTY_VALUE);
   SetIndexBuffer(1,SelTrain); SetIndexStyle(1,DRAW_ARROW,EMPTY,RazmerStrelok,colord); SetIndexArrow(1,159); SetIndexEmptyValue(1,EMPTY_VALUE);

   return(INIT_SUCCEEDED);
  }

And these conditions will never be met

   double high2=0.0,high3=0.0,high4=0.0,high5=0.0,high6=0.0,high7=0.0,size1=0.0,size2=0.0,body1=0.0,body2=0.0;

      if(Close1<Open1 && Close2>Open2
         && MathAbs(High1-High2)<=5*Point
         && high3<high2
         && high4<high2
         && high5<high2
         && high6<high2
         && high7<high2
         && body1 >= size1 * 0.7
         && body2 >= size2 * 0.7
         && size1 >= 20 * Point && size2 >= 20 * Point)
        {
         BuyTrain[i]=low[i]-OtstupStrelok*Point;
        }
      if(Close1>Open1
         && Close2<Open2
         && MathAbs(Low1-Low2)>=5*Point
         && high3>high2
         && high4>high2
         && high5>high2
         && high6>high2
         && high7>high2
         && body1 <= size1 * 0.7
         && body2 <= size2 * 0.7
         && size1 <= 20 * Point
         && size2 <= 20 * Point)
        {
         SelTrain[i]=high[i]-OtstupStrelok*Point;
        }
 

Good afternoon! The task is this - I need to determine how many bars there will be before the next 01.00 hours. I've done it so far with a loop, but maybe it's more correct to do it somehow with iBarShift? Maybe it's more correct to do it differently at all?

      int ShiftBar=0;
      for(int cnt=0; cnt<100; cnt++)
        {
         int hour=TimeHour(iTime(Symbol(),PERIOD_M30,cnt));
         if(hour==1)
           {
            ShiftBar=cnt;
            break;
           }
        }
        Print("ShiftBar= ",ShiftBar);
 
Nauris Zukas:

Good afternoon! The task is this - I need to determine how many bars there will be before the next 01.00 hours. I've done it so far with a loop, but maybe it's more correct to do it somehow with iBarShift? Maybe it's more correctly done in a different way altogether?

For a more painless transition to mql5 in the future, it would be better to use functions that are used in both languages. For searching for the number of bars it is better to use

int  Bars(
   string           symbol_name,     // имя символа
   ENUM_TIMEFRAMES  timeframe,       // период
   datetime         start_time,      // с какой даты
   datetime         stop_time        // по какую дату
   );

Actually, iBarShift() will do the job better than cycle.

Bars - Доступ к таймсериям и индикаторам - Справочник MQL4
Bars - Доступ к таймсериям и индикаторам - Справочник MQL4
  • docs.mql4.com
Bars - Доступ к таймсериям и индикаторам - Справочник MQL4
 
Alexey Viktorov:

For a more painless transition to mql5 in the future, it is better to use the functions used in both languages. For searching for the number of bars it's better to use

The iBarShift() can handle this task better than cycle.

Yes, but the problem is in finding the nearest 01.00 hours. How will you find it?
int iBarShift(
string symbol,// symbol
inttimeframe, // period
datetimetime, // time ?????????
bool exact=false // mode
);
 
Nauris Zukas:
Yes, but the problem is finding the nearest 01.00 hours. How do you determine this?
int iBarShift(
string symbol,// symbol
inttimeframe, // period
datetimetime, // time ?????????
bool exact=false // mode
);

Forum on trading, automated trading systems & strategy testing

Any questions for beginners on MQL4, help and discussion on algorithms and codes

Alexey Viktorov, 2017.07.27 13:54

If you want to make future migration to mql5 as painless as possible, use functions available in both languages. To search for the number of bars it is better to use

int  Bars(
   string           symbol_name,     // имя символа
   ENUM_TIMEFRAMES  timeframe,       // период
   datetime         start_time,      // с какой даты
   datetime         stop_time        // по какую дату
   );

In principle, iBarShift() can handle this task better than a loop.

Will return the number of bars between the specified time and the current time, if the current bar time is specified as stop_time.

The only problem is that I never fill up my memory cell with such unnecessary things as what the obtained value will be equal to, given a bar with the specified time, or less by 1. I just check every time.

 
Alexey Viktorov:

Returns the number of bars between the specified time and the current time, if the current bar time is specified as stop_time.

The only problem is, I never clog my memory cell with unnecessary stuff like what the value will be equal to, including the bar with the specified time or less by 1. I just check every time.

This I all understand, but try to get into the question. How do you find the specified time - in my case you need to find the nearest 01.00 hours. How do you write it down?
datetime start_time, // from what date ???

 
Nauris Zukas:

This I all understand, but try to get into the question. How do you find the specified time - in my case you have to find the nearest 01.00 hours. How do you write it down?
datetime start_time, // from what date ???

 datetime t=StringToTime("01:00");
 int b=Bars(_Symbol, PERIOD_M30, t, TimeCurrent());
At the current time 17:08 it shows 33. I.e. the bar number with time 01:00 will be 32.
Reason: