NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-12-2009, 09:55 AM   #1
heech
Senior Member
 
Join Date: Nov 2008
Posts: 576
Thanks: 0
Thanked 1 time in 1 post
Default XML Serialization during strategy run...?

Hi,

I just turned on XML serialization for some of my objects (using XmlSerializer), because I'm trying to feed some run-time data into a different program. This worked fine in strategy analyzer, but when I tried to run real time... NT popped up a mysterious message box warning me serialization failed while writing to database, etc, etc. (I'll try to screen capture next time.)

I'm guessing what's happening is that NinjaTrader uses the same .NET classes to serialize our strategy state...? And my custom-written attributes, etc... are some how interfering with that process? Can I get a confirmation that's the case from someone (Dierk?)?

If so, I guess the solution is to probably make the fields that are tied to my serializer private.. right?
heech is offline  
Reply With Quote
Old 03-12-2009, 09:57 AM   #2
heech
Senior Member
 
Join Date: Nov 2008
Posts: 576
Thanks: 0
Thanked 1 time in 1 post
Default

Oh, here's the actual message (captured in log):

3/12/2009 8:48:35 AM Default Failed to execute DB job 'StrategyUpdateJob': There was an error reflecting type 'NinjaTrader.Strategy.ProtectDownMulti'.: There was an error reflecting field 'states'.: There was an error reflecting type 'Chon.Utilities.SimpleState'.: Cannot serialize member 'Chon.Utilities.SimpleState.config' of type 'Chon.Utilities.SimpleConfiguration', see inner exception for more details.: Chon.Utilities.SimpleConfiguration cannot be serialized because it does not have a parameterless constructor.

... simple enough, I'll just add the parameterless constructor.
heech is offline  
Reply With Quote
Old 03-12-2009, 10:11 AM   #3
heech
Senior Member
 
Join Date: Nov 2008
Posts: 576
Thanks: 0
Thanked 1 time in 1 post
Default

Here's the next error message in the series that I can't get rid of:

3/12/2009 9:11:00 AM Default Failed to execute DB job 'StrategyUpdateJob': There was an error reflecting type 'NinjaTrader.Strategy.ProtectDownMulti'.: There was an error reflecting field 'states'.: There was an error reflecting type 'Chon.Utilities.SimpleState'.: There was an error reflecting field 'longOrder'.: There was an error reflecting type 'Chon.Utilities.SimpleOrder'.: Cannot serialize member 'Chon.Utilities.SimpleOrder.Order' of type 'NinjaTrader.Cbi.IOrder', see inner exception for more details.: Cannot serialize member Chon.Utilities.SimpleOrder.Order of type NinjaTrader.Cbi.IOrder because it is an interface.

... I think I just need to find a way for it not to try to serialize "states". I assume declaring it private will do the trick.
heech is offline  
Reply With Quote
Old 03-12-2009, 10:13 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Glad you figured it out.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-12-2009, 10:16 AM   #5
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Unfortunately this is beyond the scope we could provide support for.

Hints: As you experienced there would be multiple issues needed to be considered with XML serialization:
- parameter less constructor or no constructor at all
- marking public properties as non-serializable (XmlIgnore)
- many more...

Please consult the MS doc for a full list
NinjaTrader_Dierk 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
Strategy doesn't run in realtime rcossey73 Strategy Development 3 01-07-2009 07:37 AM
NOOB Best Practice Q:How to run a strategy shiptastic Automated Trading 1 11-13-2008 09:29 AM
Run strategy from chart and from strategy tab gaiusparx Strategy Development 1 06-30-2008 11:03 AM
Difference between strategy run on Chart and one run from Control Center richa61416 Strategy Analyzer 6 09-23-2007 05:07 AM
NT6beta11 crashes - can't run any strategy any more plipa Miscellaneous Support 13 04-17-2007 12:06 AM


All times are GMT -6. The time now is 03:48 AM.