NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 04-29-2012, 10:52 PM   #1
roland_nt
Senior Member
 
Join Date: Feb 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
Default trouble removing Text objects

Get message:
Error on calling 'OnBarUpdate' method for indicator '[routine name]' on bar 14: Collection was modified; enumeration operation may not execute.

I occasionally need to take all drawn text off the screen, Each message has a unique tag. but
RemoveDrawObject(tag) gives this message when I try to loop through all text tags.

Bar 14 is just an arbitrary staring point. Message occurs for any value.
roland_nt is offline  
Reply With Quote
Old 04-30-2012, 05:04 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello roland_nt,
Thanks for writing in and I am happy to assist you.

You cannot delete any object the collections while in a foreach loop. Thus you cannot use the RemoveDrawObjest(tag) code within the foreach loop.

This is a more of a c# query and please refer here for more details
http://stackoverflow.com/questions/6...ay-not-execute

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 05-01-2012, 03:13 PM   #3
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,356
Thanks: 24
Thanked 1,304 times in 1,067 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by roland_nt View Post
Get message:
Error on calling 'OnBarUpdate' method for indicator '[routine name]' on bar 14: Collection was modified; enumeration operation may not execute.

I occasionally need to take all drawn text off the screen, Each message has a unique tag. but
RemoveDrawObject(tag) gives this message when I try to loop through all text tags.

Bar 14 is just an arbitrary staring point. Message occurs for any value.
This thread deals with that exact issue. If you read it, you will get the code to do what you want. http://www.ninjatrader.com/support/f...ad.php?t=44194
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
Old 05-01-2012, 03:31 PM   #4
roland_nt
Senior Member
 
Join Date: Feb 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
Default deleting draw objects

Koganam

Thanks. Very helpful.
Roland
:
roland_nt is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Draw Objects djkiwi General Programming 6 03-16-2011 12:29 AM
Removing drawing objects advs108 General Programming 3 05-24-2010 02:52 PM
Removing Text velocity General Programming 5 12-21-2009 07:38 AM
removing text from screen always4nu Charting 5 10-01-2009 08:20 AM
Strategy: Removing draw objects from the chart NinjaTrader_Josh Reference Samples 0 07-23-2009 10:55 AM


All times are GMT -6. The time now is 11:00 AM.