Mt4 End of support. - page 15

 
Alexey Viktorov:

If you're willing, let's do it this way:

Do you have a function for defining a new bar? If you have it, post its code.

And immediately describe the sequence of calls to this function when we need to know the arrival of a new bar on M5, H1 and D1.

Then we will continue.

However, I do not know what for you need it. This is a skeleton for the current TF.
bool isNewBar() //true  если бар новый
  {
   static datetime last_time=0;
   datetime lastbar_time=SeriesInfoInteger(Symbol(),Period(),SERIES_LASTBAR_DATE);
   if(last_time==0)
     {
      last_time=lastbar_time;
      return(false);
     }
   if(last_time!=lastbar_time)
     {
      last_time=lastbar_time;
      return(true);
     }
   return(false);
  }
 
Mickey Moose:
I really don't know why you need it. This is a skeleton for the current TF.

Now make it return the fact of opening a new bar on M5. Then make it return the opening on H1, and then return the opening on D1

 
Mickey Moose:
I really do not know why you need it. This is a skeleton for the current TF.

Fine. What if on any timeframe we need to determine the onset of a new day? That is, a new bar on D1. What do you do in this case?

It is a consistency of a self-taught programmer to explain to another self-taught programmer the advantages of OOP. Not fully, but only the rudiments of OOP.

 
Artyom Trishkin:

Now make it return the fact of opening a new bar on M5. And then make it return the fact of opening on H1, and then return the fact of opening on D1.

Don't mock) It cannot be done universally in this style. You have to make copies for every timeframe.

 
Vitaly Muzichenko:

Don't mock) It cannot be done universally in this style. You have to make copies for every timeframe.

Don't tell me. Sit down two...

 

And Artem's stake, too.

 
Vitaly Muzichenko:

Don't mock) It cannot be done universally in this style. You have to make copies for every timeframe.

What a waste... You should have tried it yourself and come up with a simple solution - class.

 
Alexey Viktorov:

Don't tell me. Sit down two...

I came across a very succinctly written one somewhere, but I can't remember who posted it or where.

 
Artyom Trishkin:

Well, that's for nothing... You should have tried it yourself and come to a simple decision - class.

Sooner or later it comes to that if the need arises.

 
Alexey Viktorov:

And Artem's stake, too.

So I'm... I didn't...


I figured you weren't here, so I went ahead with your plan... I wouldn't just give it all away. I would have let him feel it for himself...