Help with OBJ_TEXT - How to reuse without getting stuck in a OBJECTDELETE loop. - page 2

 
Agent86 #:

Yes I think I would prefer NOT to delete if performance is effected. 

So the EA looks like this on charts and mostly works, but Text objects tend to linger sometimes. 
So I want to hide or delete as needed without getting stuck in this loops of always false somehow. 

Here is what the program looks like when running. 


If you are only keeping two objects then no need to delete them. Just keep changing there coordinates when new condition meets.

 
Thanks

This is what I have been trying to just change coordinates, but the object lingers while one condition is no longer true, and another has not yet formed. 

There is a gap in logic while waiting for the next condition to be true and reusing the object. 

It does work fine after the fact and objects changes location as expected. 

During the gap however, and sometimes when changing time frames something is stuck in memory where I might have condition A High without any B Low formation yet. 

However, there will be a B High on the chart as if there is a lingering value for B High somehow and in the wrong location. I can compile again and it's gone and the EA is as expected. 
I assume it's because old value or old object is present in memory still somehow. 

I attached the code and if you click around from time frame to time frame such as 5min, to 15min to 1hr etc. 

You will eventually see a lingering object in the wrong location that precedes where it should be located. 

My attempt to delete it have failed and effect other functions object use as well by always being false and deleted. 

Forgive my littered coded I have to reinvent once I understand a little more about objects. 

Thanks to all for the help. 
 
Agent86 #:

Yes I think I would prefer NOT to delete if performance is effected. 

So the EA looks like this on charts and mostly works, but Text objects tend to linger sometimes. 
So I want to hide or delete as needed without getting stuck in this loops of always false somehow. 

Here is what the program looks like when running. 


Hmm so in this screenshot A should be at the Low and B should be at the recent high ?

Edit : ignore that , i see you have attached the code . 

If i'm getting this right : (although the approach is not your concern)

  • You want to point from high prior breach(A) to low post breach(B) if the histogram crossed below 0 
  • You want to point from low prior breach(A) to high post breach(B) if the histogram crossed above 0 

 
Lorentzos Roussos #:

Hmm so in this screenshot A should be at the Low and B should be at the recent high ?

Edit : ignore that , i see you have attached the code . 

If i'm getting this right : (although the approach is not your concern)

  • You want to point from high prior breach(A) to low post breach(B) if the histogram crossed below 0 
  • You want to point from low prior breach(A) to high post breach(B) if the histogram crossed above 0 

So the code mostly works as expected as the screenshot shows at that point it's working as expected. 

However, there are 2 things that happen that I can't fix. 

1) when changing from time frame to time frame sometimes B appears at a location prior to A where a new B has not yet formed
2) after some time when histogram crosses in a new direct, and a new A is formed. The old B still persists and I wish to delete/hide it. 

Note:
If the faulty B exists I can recompile or change time frames and go back to the original time frame and the faulty B "might" disappear and then the current A,B's seem corrected. 
This is not always the case but mostly what is happening.

The main most concerning is that If you let the charts run and after sometime, the old B will persist until a new B is found. This is the one that I thought I should delete until a new B is found.  

Once the objects are found the A,B moves to my correct coordinates/times.

Oops forgot to include the MACD True indicator too. 



Files:
MACD_True.mq4  4 kb
 
Agent86 #:

I see. 

This is exactly the problem I have where condition gets locked to false condition once my condition is true and I need to unlock or change method somehow. 

As you can see my code does exactly as you described. Stuck on false. 
This give me some ideas to work on sort of a toggle switch. 

What happens when Bid<1.12345 ?
Bid>=1.12345

Doesn't this make it always false again when Bid goes below 1.12345 ?  
 


Well

This code

        if(Bid>=1.12345)
           my_condition=true;
        else
           my_condition=false;  

is just an example

The price described is a level...but market generally floats so sometimes the price will be higher than the specified level and sometimes lower.

This causes condition to change and unlock some other futures of the programe.

This is what you should focus on. If you want to create an object in certain conditions and delete it in other case, sometimes you need an extra boolean variable

to memorize the position of "toggle switch".

Work on the conditions.

 
Piotr Latoszynski #:

Well

This code

is just an example

The price described is a level...but market generally floats so sometimes the price will be higher than the specified level and sometimes lower.

This causes condition to change and unlock some other futures of the programe.

This is what you should focus on. If you want to create an object in certain conditions and delete it in other case, sometimes you need an extra boolean variable

to memorize the position of "toggle switch".

Work on the conditions.

Thanks