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

 
@Konstantin Nikitin Got it, thanks!
 
Rewerpool:
@Konstantin Nikitin Are you suggesting to take these parameters outside the function body? Or leave them as I wrote in the last screenshot?
Of course, they must be outside the function. You're constantly updating and comparing them by calling this function.
 
Konstantin Nikitin:

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

Static - no.
 
Konstantin Nikitin:
Of course, it is outside the function. You are constantly updating and comparing them by calling this function.
You are prompting yourself with little idea of what...
 
Artyom Trishkin:
You're telling yourself little by little what...

Did you originally look at the function itself???

void NOTIFICATION()
{

int DayT=0,BarTime;
 if(DayT!=Day())// Если новый день - нужно опросить
 {
 DayT=Day();
//......
}
if (BarTime==Time[0]) // Если новый бар - нужно опросить
{
   BarTime=Time[0];
//......
}
}

And how are DayT BarTime supposed to change here? They will always be wound 0.

if(DayT!=Day())

It will always work as the truth, and

if (BarTime==Time[0])

as a lie.

 
Konstantin Nikitin:

Did you look at the function yourself initially???

And how are DayT BarTime supposed to change here? They will always be 0.
You said put them in global variables. It's enough to make them static, not drag everything into one pile.
 
Artyom Trishkin:
You said to put them in global variables. It's enough to make them static, not to put them all in one pile.
It's up to your liking, but they weren't declared correctly in the first place.
 

It turns out you can also do this????

void NOTIFICATION()
{
static int DayT=0;
static 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());
}
}
 
And if I take them to a global level, they can also be queried from other functions
 
Rewerpool:
And if I put them on a global level, they can also be queried from other functions
Not the right approach.