Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
Any ideas?
Can you help answer these questions from other members on NexusFi?
Good. This is the official function. Due the fact NT can delete all objects and it is not running as an OS in a privileged mode there is a function which can delete manually added draw objects.
Has somebody a control in mind I can start to check? It must be a non public method...
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.
You can remove drawobjects individually.
If you use say "XYZ" +Current bar as your tag you can do the following
int numprior = num -1;
StringBuilder newstring = new StringBuilder();
newstring.Append("XYZ" + numprior);
string stringconvert = newstring.ToString();
RemoveDrawObject(stringconvert);
this removes the prior bar object.
I am sure there is a more elegant way but it's like using NT8 - beyond me!!