I am dynamically calculating, drawing, and removing of support/resistance rectangles starting at the current time until end of session time on the chart throughout for each session on the chart. The actual number of rectangles will vary based on user parameters input. The user can specify how many support/resistance levels he wants for a specified tick range so I rank them and only show that number of rectangles.
Question:
What is my most efficient method of checking if a drawing object rectangle already exists on the chart? My thinking is to track what I have currently drawn in an array and not draw it again if the tag name (tag name = session date + price) currently exists in the array. When a rectangle is no longer in effect I will redraw the rectangle shorter than the end of session time and remove the tag name from the array so I can see where rectangles were at each point in time in the past for post analysis. I could check for the actual existence of the draw object on the chart but it did not seem to be the most effective method to me so I thought I would ask you the experts for your thoughts.
The indicator works well but does many calculations so is a resource pig but trying to reduce any unneeded over head I can. I allow a user specified frequency in an added time fame be that every every few seconds or minutes for a timing trigger so the logic only executes as frequently as the user decides and is independent of the chart time frame.
I hope the above makes sense. Thanking you in advance.
Cheers

Comment