Program not updating as it is supposed to

 
Hey guys
So I coded a program that will look for all the rectangles on chart then change the color based on certain conditions. Now the problem I'm encountering is that when for example I draw one rectangle even if the condition is met the color don't change but as soon as I create a new rectangle, the first now change color based of the conditions. Same for the newly created rectangle, even if conditions are met, color won't change unless I create a new. Seems like conditions don't work on the last rectangle drawn or something like that. If anyone can help. Will be nice.
 
Bryan Djoufack Nguessong:
Hey guys
So I coded a program that will look for all the rectangles on chart then change the color based on certain conditions. Now the problem I'm encountering is that when for example I draw one rectangle even if the condition is met the color don't change but as soon as I create a new rectangle, the first now change color based of the conditions. Same for the newly created rectangle, even if conditions are met, color won't change unless I create a new. Seems like conditions don't work on the last rectangle drawn or something like that. If anyone can help. Will be nice.

You can help yourself. Use the Debugger to see where and why your program acts different as you planned it.

Read this to know how: https://www.mql5.com/en/articles/654

Debugging MQL5 Programs
Debugging MQL5 Programs
  • www.mql5.com
This article is intended primarily for the programmers who have already learned the language but have not fully mastered the program development yet. It reveals some debugging techniques and presents a combined experience of the author and many other programmers.
 

Make sure you call ChartRedraw every time you change an object's properties so the change is reflected on the chart.

The docs say it's only necessary when you change an object's properties, and I don't program for MT5 much, but if you also create / delete an object and the change isn't reflected, try calling ChartRedraw afterwards.

 
Alexander Martinez #:

Make sure you call ChartRedraw every time you change an object's properties so the change is reflected on the chart.

The docs say it's only necessary when you change an object's properties, and I don't program for MT5 much, but if you also create / delete an object and the change isn't reflected, try calling ChartRedraw afterwards.

Yeah, I called ChartRedraw eachtime I modified properties just after

 
Carl Schreiber #:

You can help yourself. Use the Debugger to see where and why your program acts different as you planned it.

Read this to know how: https://www.mql5.com/en/articles/654

Thanks for reply but sadly it's a mql4 program not mql5

 
Bryan Djoufack Nguessong:
Hey guys
So I coded a program that will look for all the rectangles on chart then change the color based on certain conditions. Now the problem I'm encountering is that when for example I draw one rectangle even if the condition is met the color don't change but as soon as I create a new rectangle, the first now change color based of the conditions. Same for the newly created rectangle, even if conditions are met, color won't change unless I create a new. Seems like conditions don't work on the last rectangle drawn or something like that. If anyone can help. Will be nice.
It is working, check the naming or have a function delete the old rectangle to create a new one, in as much as the object is already on the chart with the same name, a new one won't be created.
 
Bryan Djoufack Nguessong #: Thanks for reply but sadly it's a mql4 program not mql5

irrelevant, both have the debugger.

 
Thank-god Avwerosuoghene Odukudu #:
It is working, check the naming or have a function delete the old rectangle to create a new one, in as much as the object is already on the chart with the same name, a new one won't be created.

Resolved. Thanks for reply

 
William Roeder #:

irrelevant, both have the debugger.

Resolved. Thanks for help

 
Alexander Martinez #:

Make sure you call ChartRedraw every time you change an object's properties so the change is reflected on the chart.

The docs say it's only necessary when you change an object's properties, and I don't program for MT5 much, but if you also create / delete an object and the change isn't reflected, try calling ChartRedraw afterwards.

Resolved. Thanks for help

Reason: