I create small trend lines to augment an indicator that I use. The drawing of the trend lines work perfect. However, when the chart has scrolled past the number of bars that MT4 is set to, the objects seems to pile up.
The trend line has a open time and a close time in the ObjectCreate()
command (as shown below):
bool bSuccess = ObjectCreate( 0, sName, OBJ_TREND, iIndicatorWindow,
dtOpenTime, dOpenPrice,
dtCloseTime, dClosePrice
);
I would think that as the bar scrolls off the screen, the corresponding trendline will be deleted as well.
Could you please let me know if I need to delete the objects that scroll off programatically (instead of waiting for MT4 to delete them)?
Once created, objects remain alive, does not matter how much time passed. If you need - try to delete the object, if not - leave it and seek for the newest object (loop over ObjectsTotal()
) to find the newest one that meets your criteria.