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

 
Bek001:

Let me put it another way. How can you determine the maximum price in the last 10 seconds?

In MT5 - CopyTicks()

In MT4 - save ticks in array of structures MqlTick. From it, take max/min prices.

 

Can you tell me how to do this? I wrote a notification function and the notifications come on every tick! The function itself is just written in int Start. PATTERN conditions on M30.

///--------------------------------------------------------------------------------------------
/// ФУНКЦИЯ ОТПРАВКИ УВЕДОМЛЕНИЙ
///--------------------------------------------------------------------------------------------
void NOTIFICATION()
{

int DayT=0,BarTime;
 if(DayT!=Day())// Если новый день - нужно опросить
 {
 DayT=Day();
if(Push_On&&DAY_HIGH())SendNotification("ДЕНЬ ЗАКРЫЛСЯ ВЫШЕ ЛИНИИ -" + Symbol());
if(Push_On&&DAY_LOW())SendNotification("ДЕНЬ ЗАКРЫЛСЯ НИЖЕ ЛИНИИ -" + Symbol());
}
if (BarTime==Time[0]) // Если новый бар - нужно опросить
{
   BarTime=Time[0];
if(Push_On&&DAY_HIGH()&&PATERN_BUY())SendNotification("ДЕНЬ ЗАКРЫЛСЯ ВЫШЕ ЛИНИИ + ПАТТЕРН -" + Symbol());
if(Push_On&&DAY_LOW()&&PATERN_SELL())SendNotification("ДЕНЬ ЗАКРЫЛСЯ НИЖЕ ЛИНИИ + ПАТТЕРН -" + Symbol());
}
}
 
Rewerpool:

Can you tell me how to do this? I wrote a notification function and the notifications come on every tick! The function itself is simply written in int Start.

static int DayT=0;
 
@Artyom Trishkin Thank you! Interesting came out now it's quiet at all!
 
Rewerpool:
@Artyom Trishkin Thank you! Interesting came out now it's quiet at all!
It's hard to read the code from a mobile. There's probably something else wrong there.
 
Rewerpool:

Can you tell me how to do this? I wrote a notification function and the notifications come on every tick! The function itself is just written in int Start. PATTERN conditions on M30.

int DayT=0;
datetime BarTime=TimeCurrent();
void NOTIFICATION()
{
   if(DayT!=Day())// Если новый день - нужно опросить
   {
      DayT=Day();
      if(Push_On&&DAY_HIGH())SendNotification("ДЕНЬ ЗАКРЫЛСЯ ВЫШЕ ЛИНИИ -" + Symbol());
      if(Push_On&&DAY_LOW())SendNotification("ДЕНЬ ЗАКРЫЛСЯ НИЖЕ ЛИНИИ -" + Symbol());
   }
   if (BarTime==Time[0]) // Если новый бар - нужно опросить
   {
      BarTime=Time[0];
      if(Push_On&&DAY_HIGH()&&PATERN_BUY())SendNotification("ДЕНЬ ЗАКРЫЛСЯ ВЫШЕ ЛИНИИ + ПАТТЕРН -" + Symbol());
      if(Push_On&&DAY_LOW()&&PATERN_SELL())SendNotification("ДЕНЬ ЗАКРЫЛСЯ НИЖЕ ЛИНИИ + ПАТТЕРН -" + Symbol());
   }
}

You declare variables and immediately compare with them. Of course you always get the same result.

 
Artyom Trishkin:
It's hard to read the code on a mobile. There must be something else wrong with it.

I think it should have gone like this

datetime BarTime;
 

@Konstantin Nikitin Hello!!! Fixed it!!! Daily signals are up! Still need to check the intraday ones!

Fixed! Here:

///--------------------------------------------------------------------------------------------
/// ФУНКЦИЯ ОТПРАВКИ УВЕДОМЛЕНИЙ
///--------------------------------------------------------------------------------------------
void NOTIFICATION()
{

static int DayT=0;
datetime BarTime;
 if(DayT!=Day())// Если новый день - нужно опросить
 {
 DayT=Day();
if(Push_On&&DAY_HIGH())SendNotification("ДЕНЬ ЗАКРЫЛСЯ ВЫШЕ ЛИНИИ -" + Symbol());
if(Push_On&&DAY_LOW())SendNotification("ДЕНЬ ЗАКРЫЛСЯ НИЖЕ ЛИНИИ -" + Symbol());
}
if (BarTime==Time[0]) // Если новый бар - нужно опросить
{
   BarTime=Time[0];
if(Push_On&&DAY_HIGH()&&PATERN_BUY())SendNotification("ДЕНЬ ЗАКРЫЛСЯ ВЫШЕ ЛИНИИ + ПАТТЕРН -" + Symbol());
if(Push_On&&DAY_LOW()&&PATERN_SELL())SendNotification("ДЕНЬ ЗАКРЫЛСЯ НИЖЕ ЛИНИИ + ПАТТЕРН -" + Symbol());
}
}
 
Rewerpool:

@Konstantin Nikitin Hello!!! Fixed it!!! Daily signals are up! Still need to check the intraday ones!

Fixed! Here:

static int DayT=0;
datetime BarTime;

Take it to the global level. You will always have them equal to 0, because each time the function is called, a new one will be declared.

 
@Konstantin Nikitin Are you suggesting to take these parameters outside the function body? Or leave them as I wrote in the last screenshot?
Reason: