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

 
Alexey Viktorov:

In OnChartEvent, you also need to know the exact name of the object. And you don't have one until you have the object itself.

It is, on creation, in sparam.

In general, it works in OnChartEvent, but it doesn't work in the tester.

 
Andrey Sokolov:

It is, on creation, in sparam.

In general, it works in OnChartEvent, but it doesn't work in the tester.

Try this logic:

if there is a new object ...

 
Andrey Sokolov:

It is, on creation, in sparam.

In general, it works in OnChartEvent, but it doesn't work in the tester.

But what should I compare it to? How do you distinguish that this is the right object? How do you know it works on the same tick?

Artyom Trishkin:

Try this logic:

If there is a new object ...

It's going to be on the next tick, no matter how hard it is.

 
Artyom Trishkin:

Try this logic:

if there is a new object ...

Please clarify how exactly

 
Alexey Viktorov:

But what do you compare sparam to? How can you tell if it's the right object? The name part.

How can you tell if it works on the same tick? - By outputting it to print.

 
Andrey Sokolov:

But what do you compare sparam to? How can you tell if it's the right object? The name part.

How can you tell if it works on the same tick? - Print output.

1. Look at the other objects to see if those parts of the name match.

2. Does it print out the time in seconds? And how often are there ticks?

 
Alexey Viktorov:


It's going to be, as it were, on the next tick.

Well wait..., in a millisecond timer we can know the current Volume. As long as Volume has not changed (current tick) we check if a new object has appeared. As soon as past number of objects is not equal to current number of objects, while current Volume is equal to past Volume - caught appearance of some object inside current tick - do what you need.
Or am I mistaken? It should be checked...

SZZ. As we see it - when new object appears in timer, we send user event, in which we write necessary information. All processing of new object occurence in this way will be done in event handler. And it's not sure that the assumption is correct and it's worth the trouble...

 
Artyom Trishkin:

Wait a minute, in a millisecond timer we can know the current Volume. As long as Volume hasn't changed (current tick) we check if a new object appeared. As soon as past number of objects is not equal to current number of objects, while current Volume is equal to past Volume - caught appearance of some object inside current tick - do what you need.
Or am I mistaken? It should be checked...

SZZ. As we see it - when new object appears in timer, we send user event, in which we write necessary information. All processing of new object occurence in this way will be done in event handler. And it's not sure that the assumption is correct and it's worth the trouble...

If not in the tester, OnChartEvent is enough, but in the tester neither timer nor OnChartEvent work.

So far, the issue is to make it work in the tester on the same tick.

 
Alexey Viktorov:

1. Look at the other objects to see if these parts of the name match. - That's good enough for me.

2. Does it print the time in seconds? How often do the ticks occur? - There is no noticeable delay, you can see for yourself, the code is minimum

 
Artyom Trishkin:

Wait a minute, in the millisecond timer we can know the current Volume. As long as Volume hasn't changed (current tick) we check if a new object appeared. As soon as past number of objects is not equal to current number of objects, while current Volume is equal to past Volume - caught appearance of some object inside current tick - do what you need.
Or am I mistaken? It should be checked...

SZZ. As we see it - when new object appears in timer, we send user event, in which we write necessary information. All processing of new object occurence in this way will be done in event handler. And it's not sure that the assumption is correct and it's worth the trouble...

As I understand the task:

On one chart there is an indicator that draws marks and an EA that reads these marks.

The Expert Advisor needs to read on one tick the mark that the indicator drew on the same tick. Where is the guarantee that the indicator will work faster than the Expert Advisor? The event will occur simultaneously in the indicator and in the Expert Advisor. Secondly, even in one code, after ObjectCreate it is impossible to read the object properties, despite the fact that the object has already been created.

I highly doubt the possibility of such a stunt. But I would be very happy if I was wrong.

Reason: