NexusFi: Find Your Edge


Home Menu

 





RemoveDrawObject does not remove User objects from the Chart


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one AlBundy with 3 posts (2 thanks)
    2. looks_two Mindset with 2 posts (0 thanks)
    3. looks_3 Goldy with 1 posts (0 thanks)
    4. looks_4 aiforus with 1 posts (1 thanks)
    1. trending_up 4,991 views
    2. thumb_up 3 thanks given
    3. group 5 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

RemoveDrawObject does not remove User objects from the Chart

  #1 (permalink)
 
AlBundy's Avatar
 AlBundy 
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 12

Hi,

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?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
NexusFi Journal Challenge - May 2024
Feedback and Announcements
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
70 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Bigger Wins or Fewer Losses?
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
The Program
20 thanks
  #2 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


AlBundy View Post
Hi,

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?


You can apply different indicators to your chart. When you use RemoveDrawObjects() within one indicator, it will not

- remove draw objects created via any other indicator or strategy
- remove draw objects that you have manually added

This is as expected.

You can remove manually added draw objects manually.

Reply With Quote
  #3 (permalink)
 
AlBundy's Avatar
 AlBundy 
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 12



Fat Tails View Post
You can apply different indicators to your chart. When you use RemoveDrawObjects() within one indicator, it will not

- remove draw objects created via any other indicator or strategy
- remove draw objects that you have manually added

This is as expected.

You can remove manually added draw objects manually.

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...

Started this thread Reply With Quote
  #4 (permalink)
 
AlBundy's Avatar
 AlBundy 
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 12

SOLVED!


aiforus View Post
1) Use Reflection to get extra information on undocumented methods and fields at runtime (write your own code in indicator)
2) Try to get extra information from NT .NET assemblies using software such as Reflector

Yes, Reflector was the key to success. I found a solution how to remove manually drawn objects from the chart:

 
Code
BindingFlags bfObject = BindingFlags.Instance | BindingFlags.NonPublic;
MethodInfo methodNT = typeof(ChartControl).GetMethod("RemoveDrawingObjectsAfterBar", bfObject);
methodNT.Invoke(this.ChartControl, new Object [] { 0 });

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.

Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 Goldy 
Bremen Germany
 
Experience: Advanced
Platform: NinjaTrader, MT4 and others
Trading: EURUSD
Posts: 2 since Jan 2012
Thanks Given: 0
Thanks Received: 1

Hi AlBundy,

I'm looking for a solution for the same problem. I would like to delete manually drawn traingle by indicator. Would you give me your code?

Reply With Quote
  #6 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291


AlBundy View Post
Hi,

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?

Hi

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!!

Reply With Quote
  #7 (permalink)
 
Mindset's Avatar
 Mindset 
Singapore
 
Experience: Intermediate
Platform: NT
Broker: ib
Trading: MES
Posts: 365 since Sep 2009
Thanks Given: 90
Thanks Received: 291


Mindset View Post
Hi

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!!

Edit - Sorry this doesn't quite work as expected - my bad.

Reply With Quote




Last Updated on May 8, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts