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

 
voron_026:

Solved the problem with drawing a large number of objects. Set the check on the new bar. The code turned out like this:

The only thing is that in object properties the serial number of the arrow goes not 1 2 3 ... and so on, but 1 850427 1083295 ..... I take it the counter doesn't work correctly?

My question is, how to check for a new bar on H4. In other words, the robot should look for the patterns on H4, while the chart may be on any TF?

You do not need to look for a new bar and check it.

It is enough to attach bar opening time to the arrow name. And then check the arrow with this name - if it does not exist yet, create it, if it already exists, nothing needs to be done. The name should be checked directly in the arrow creation function.

 
voron_026:

Solved the problem with drawing a large number of objects. Set the check on the new bar. The code turned out like this:

The only thing is that in object properties the serial number of the arrow goes not 1 2 3 ... and so on, but 1 850427 1083295 ..... I take it the counter doesn't work correctly?

My question is, how to check for a new bar on H4. In other words, the robot should look for the patterns on H4, and the chart may be in any TF?


Do you need an Expert Advisor or an indicator?

An indicator would be better...

I mean that the new bar may be checked forcedly on H4, not on the current timeframe.

 
Artyom Trishkin:

You don't need to look for a new bar and check.

All you have to do is add the opening time of the bar to the name of the arrow. And then check the arrow with this name - if it doesn't exist yet, create it, if it already does, you don't need to do anything. The name should be checked directly in the arrow creation function.


Wouldn't it be more costly to search through all the objects for a name?

In any case, the master code would be interesting to see.

 
Aleksey Vyazmikin:

Wouldn't it be more costly to search through all the objects for a name?

In any case, the code of the wizard would be interesting to see.

This is, as I understand it, a template for the EA. With the name, Artyom said it right.

 
Vitaly Muzichenko:

This is, as I understand it, a template for an advisor. With the name, Artem said it correctly.


Yes a lot depends on the EA, if it only trades on the opening of a candle, then the decision is correct with checking a new candle.

But what is the point(advantage) of checking all objects for current time - I don't know ... but it is interesting to see this approach too.

 
Aleksey Vyazmikin:

Yes, a lot depends on the EA, if it trades only on the opening of a candle, then the decision is correct with checking for a new candle.

But what is the point (advantage) of checking all objects for current time - I don't know... but it is interesting to see this approach.

There is no need to search for any objects. For this there is function ObjectFind

ObjectFind - Графические объекты - Справочник MQL4
ObjectFind - Графические объекты - Справочник MQL4
  • docs.mql4.com
ObjectFind - Графические объекты - Справочник MQL4
 
Alexey Viktorov:

There is no need to search for any object. There is a function ObjectFind for that


From the description"It searches for an object with the specified name. There are two variants of the function:" it can only search by brute force...

 
Aleksey Vyazmikin:

From the description"It searches for an object with the specified name. There are two variants of the function:" it can only search by brute force...

Go for it.
 
Artyom Trishkin:
Go ahead.

I knew about this operator, and I understood that it can only find the right variant by brute force.

Perhaps it is not so long - I do not know exactly - I did not do experiments - I hoped that you have great knowledge to tell me whether it is so or not, but you have led the conversation in a completely different direction ...

 
Aleksey Vyazmikin:

I knew about this operator, and I understood that it can only find the right variant by brute force.

Perhaps it is not so long - I do not know exactly - I have not made any experiments - I hoped that you have great knowledge to tell me whether it is true or not, but you have led the conversation in a completely different direction ...

Where is the other direction?

This is the forum for trading, automated trading systems and testing of trading strategies.

Any MQL4 beginners questions, help and discussion on algorithms and codes

Artyom Trishkin, 2017.09.19 22:39

You don't need to look for a new bar and check it.

All you need to do is add the bar open time to the arrow name. And then check the arrow with that name - if it doesn't exist yet, then create it, if it already does, then you don't need to do anything. The name should be checked directly in the arrow creation function.