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

 
Maxim Kuznetsov:

Read the documentation already :-) Period() returns just the id of the current period - why are you multiplying by it?

instead of PERIOD_M1 (which is given as an example), pass it to PeriodSeconds( Period() ) - then get how many seconds in 1 bar of the current period.

Anyway, the M15 chart puts the arrow on the bar that opened at 20:00 but the time specified is inside the bar that opened at 19:45. What is it?

 {
//---
   if(rates_total<2) return(0);

   int limit=rates_total-prev_calculated;
   if(limit>1)
     {
      limit=rates_total-2;
      ArrayInitialize(BufferUP,EMPTY_VALUE);
      ArrayInitialize(BufferDN,EMPTY_VALUE);
     }
   for(int i=limit; i>=0; i--)
     {
     
      if(time[i]>=StringToTime("2019.04.23 19:55:00") && time[i]<StringToTime("2019.04.23 19:55:00")+PeriodSeconds(Period()))
        {
         BufferUP[i]=low[i]-10*Point;//
        }

     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
 
yiduwi:

Still on the M15 chart puts the arrow on the bar that opened at 20:00 but the specified time is in the bar opened at 19:45. What is it?

the code has become more compact and at least you already see what you want to see :-)

 for(int i=limit; i>=0; i--)
     {
     
      if(time[i]<=StringToTime("2019.04.23 19:55:00") && time[i]+PeriodSeconds(Period())>StringToTime("2019.04.23 19:55:00") )
        {
         // время открытия текущего бара time[i] меньше искомого
         // но время закрытия (открытие+длительность) больше искомого
         // значит нужное вам время - внутри бара, можно нарисовать стрелку
         BufferUP[i]=low[i]-10*Point;
        }

     }

but if you make a "player" of deals, it is only for the history part ;-)
otherwise arrows will appear "from the future" - at the moment when the bar opens, and you will cheat yourself
...
there should be another branch of algorithm, that works with ticks and TimeCurrent()

 
Maxim Kuznetsov:

Otherwise arrows will appear "from the future" - at the moment of bar opening

Yes, it will open on H1 at the start of the hour even if the time is 01:59:00

Maybe there is a way to check if the opening of the bar on M1 is equal to 01:59:00 or any other time ?

 
Which function can check whether there is a connection to the server or not, I want to write a format condition that if there is no connection to the office's server then do something?
 
Seric29:
Which function can check whether there is a connection with the server or not, I want to write a condition in the format that if there is no connection with the server of the office, then wh
Here
IsConnected - Проверка состояния - Справочник MQL4
IsConnected - Проверка состояния - Справочник MQL4
  • docs.mql4.com
IsConnected - Проверка состояния - Справочник MQL4
 

Good afternoon everyone, can you tell me whether the chart tabs can be changed programmatically? What is the best way to do this. Thank you in advance!

 
yiduwi:

Can the function

IsConnected();

Called before the entire program is initialised, so that it is executed before the rest of the code is read, you mean before the OnInit function? If yes, can you tell me how? In fact, this function is useless without receipt of ticks.

 
Seric29:

Is it possible to

Call before initialising the whole program, so that it is executed before the rest of the code is read? If so, can you tell me how? Basically, without ticks coming in, this function is useless.

You can do it without the ticks.

 
Hello, which constructor can create one indicator from several different indicators. Please give me a link or the name of the program.
 

hello! please help how to put in RSI alert, push notifications tried it myself it does not work gives out error

LOCKED CODE DELETED

Настройки платформы - Начало работы - MetaTrader 5
Настройки платформы - Начало работы - MetaTrader 5
  • www.metatrader5.com
Торговая платформа обладает множеством настроек, что позволяет организовать работу в ней так, как это удобно именно вам. Выполните команду " Настройки" меню "Сервис" или нажмите "Ctrl+O". Графики — общая настройка отображения ценовых графиков, а также настройка параметров управления объектами: выделение объектов после их создания, немедленная...
Reason: