Indicate a new bar - page 3

 

Hi Alain,

thank you for your comment and improvements.

I should go back to my first version in which "bool NewBar" is a global variable switch by a function call in OnTick().

Or I make a small object of it. Maybe the smartest option.


And - of cause - "never do the same calculation twice".

Helmut

 
datetime iTime[];
datetime recent;
datetime projection;
int OnInit()
  {
//---
  int pull=CopyTime(NULL,0,0,1,iTime);
  recent=iTime[0];
  projection=recent+PeriodSeconds();
//---
   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
//---
  if(TimeCurrent()>=projection)
   {
   Print("New Bar "+TimeToString(projection,TIME_DATE|TIME_MINUTES));
   projection=projection+PeriodSeconds();
   }
  }
 

@ Doerk Hilger

The language is the same but they have a small subset of functions not in common

Oh my God ... definitely not!

As MQ pointed out on the product description

MetaQuotes Language 5 is based on the concepts of the well known and popular С++ programming language. MQL5 is also a high-level object oriented programming language.

https://www.metatrader5.com/en/automated-trading/mql5

Beside some differences in the handling of structures, pointers and addresses, the biggest point is: MQL5 provides all the features of an object oriented program language which allows a completely different programming paradigm. From this point of view MQL5 clearly belongs to another class and also another generation of languages than MQL4.

Another advantage is the speed. Can’t remember where I read this: MQL5 is a hundred times faster in execution then MQL4.

And here comes the downside: It's faster in execution BUT creating a program is very very slow if you need to familiarize youself with concepts of programing on a professional level first.

Which leads to the problem of MQ. On the one hand they need to offer a modern professional development environment in order to get or hold the market of professionals, on the other hand they cannot allow themselves to lose all the private and semiprofessional clients which are interessetet in trading and not in programing science.




 
MQ did a lot to generate confusion at this point. 

Maybe you are right.      

Let’s see, what we can do, to bring more clearness into this issue.

I think, it would be very helpful, if people would post their MQL4 issues in the MQL4 forum,  while those, having MQL5 questions, should post in the MQL5 forum. 

Sounds very easy . . . what do you think?

In the beginning, it would be serviceable if the moderator would move wrong posting to the right forum, leaving an hint “sorry, wrong forum – see …”.

Willbur

 

@Lorentzos Roussos

It's getting easier and easier ;-)

What I worry about is the question wether TimeCurrent() is syncron with the bars in all cases.

I am going to do some 2h tests on monday.

Willbur



 
should be: 24 h
 
Willbur:

@Lorentzos Roussos

It's getting easier and easier ;-)

What I worry about is the question wether TimeCurrent() is syncron with the bars in all cases.

I am going to do some 2h tests on monday.

Willbur



Alain can correct me on this but you may find gaps in instances where on the time horizon of a bar there where no ticks , so no bar will be in place.
 
Willbur:

@ Doerk Hilger

Oh my God ... definitely not!

As MQ pointed out on the product description

Beside some differences in the handling of structures, pointers and addresses, the biggest point is: MQL5 provides all the features of an object oriented program language which allows a completely different programming paradigm. 




Definitely yes :) But I know what you mean, I always thought I am programming MQL5, because I code only object oriented but as I learned now, its "Enhanced" MQL4 since built 600 which is simply nothing else than MQL5 but, just as told, with small differences at the functions subset - and since this built MQL4 is no more another language. Actually, Enhanced-MQL4 is MQL5 for MetaTrader4. Thats what I meant by the confusion part. For me, MQL5 always was OOP and MQL4 was only top-down-spaghetti. And I dont like spaghetti ;)

 

Edit: Where is your statement above taken from and when did they post this? Because actually it would mean, that the first assumption was right: It is MQL5 .... confusion at its highest level ;) 

 
I love spaghetti.
 
Doerk Hilger:

Definitely yes :) But I know what you mean, I always thought I am programming MQL5, because I code only object oriented but as I learned now, its "Enhanced" MQL4 since built 600 which is simply nothing else than MQL5 but, just as told, with small differences at the functions subset - and since this built MQL4 is no more another language. Actually, Enhanced-MQL4 is MQL5 for MetaTrader4. Thats what I meant by the confusion part. For me, MQL5 always was OOP and MQL4 was only top-down-spaghetti. And I dont like spaghetti ;)

 

Edit: Where is your statement above taken from and when did they post this? Because actually it would mean, that the first assumption was right: It is MQL5 .... confusion at its highest level ;) 

Enhanced-MQL4 ?

Never heard of that. 

Maybe you should read the documentation on both platforms before convincing yourself that you know what you are doing.

Reason: