RemoveDrawObject does not remove User objects from the Chart
can it be the function RemoveDrawObject() does not delete objects which the user has added manually to the chart? I checked it many times and that far I do not see any problem/bug in the code. I can remove objects which the indicator created but when I try to remove an object which has been added by the user to the chart it does not work. Neither when I reference it by the tag, nor by the object id directly [RemoveDrawObject() has 2 overloads].
The behaving does not change if I lock/unlock the object or to what ever I assign it.
It looks for me NinjaTrader framework does not allow the C# code delete objects which have been created by the user.
Yes, Reflector was the key to success. I found a solution how to remove manually drawn objects from the chart:
This method may not be for all suitable because it is deleting all drawn objects [also the objects drawn from any indicator] from the chart. I did not want to spend more time to investigate because it works for me.
Due the fact I have all drawn objects created by the indicator in an internal structure I just repaint them after calling the Invoke method and then I invalidate and refresh the chart. It goes that fast that it looks very smooth and indeed only the manually drawn objects are deleted.
If somebody finds a better solution please post it.
The following 2 users say Thank You to AlBundy for this post: