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 11-26-2008, 05:26 PM   #1
shawnj
Senior Member
 
Join Date: Jan 2005
Location: , ,
Posts: 218
Thanks: 0
Thanked 0 times in 0 posts
Default Serialization Error

I've written an indicator that compiles and runs clean however when I try to save it in a workspace I get a Serialization error that says to look up Serialization in the help.

1) I dont see anything about serialization in the help.

2) What could possibly be causing this? How would you debug something like this?

thanks,
shawnj
shawnj is offline  
Reply With Quote
Old 11-26-2008, 05:56 PM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,558
Thanks: 261
Thanked 1,015 times in 996 posts
Default

Hi shawnj,

Please consider repairing your database with those instructions below -

1. Disconnect NinjaTrader from any open connections via File > Disconnect

2. From the NinjaTrader Control Center window select the menu Tools > Options

3. Select the "Misc" tab

4. Press the "Repair DB" button

5. Press the "OK" button

Then bring up a chart and try to save this with your indicator applied to a workspace and see if the issue persists.

Happy Thanksgiving!
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 11-26-2008, 08:07 PM   #3
shawnj
Senior Member
 
Join Date: Jan 2005
Location: , ,
Posts: 218
Thanks: 0
Thanked 0 times in 0 posts
Default

Always with the Repair DB <g>. Is NT's database that fragile or is this what the new guy is taught to tell anyone who writes in with a problem <GG>.

Well, repairing the database did not fix the problem.

Here is a screenshot of the error message.

Again my original questions:

1) as per the error dialog, where is the help for more info on serializing indicators.

2) what could be causing this (other than the database) and how can I troubleshoot it?

Logic would dictate, If the code compiles, we should not see an error like this.
Attached Images
File Type: png MyWontSerializeIndicatorMessageDialog.PNG (6.9 KB, 58 views)
shawnj is offline  
Reply With Quote
Old 11-27-2008, 06:09 AM   #4
TAJTrades
Senior Member
 
Join Date: Dec 2007
Location: Atlanta
Posts: 281
Thanks: 0
Thanked 4 times in 3 posts
Default

shawnj;

I recall getting the same errors a while back. After much backtracking on the code my issue was with "Exposing" DataSeries and BoolSeries. Basically everything that is not a Plot needs to follow the exact procedure in the sample file ("Exposing Bool Series" i think) if you want other Indicators and Strategies to have access to them. There is an Indicator file that creates the series and a Strategy file that receives the series in the Zip Package. The reason I bring that up is that it took me a while to realize there were two files .

I do not know if your code requires the above but if it does I would start there.

T
TAJTrades is offline  
Reply With Quote
Old 11-27-2008, 06:52 AM   #5
shawnj
Senior Member
 
Join Date: Jan 2005
Location: , ,
Posts: 218
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks T.

In case this might help someone else:
After a bunch of blocking out chunks of code and trying to serialize again, I've roughly zeroed in on the problem. I say roughly because I tried to write a stripped down indicator that would duplicate/document the exact problem and I have not been unable to find the exact combination that is causing it .

However, this is how I "fixed" my indicator. This indicator has an embedded class. I wrote the constructor for that class to take a set of parameters. Adding a default constuctor (no parameters) "fixed" it.

I've now added a new step to my indicator development workflow:
-After a few hundred clean compiles, test the serialization .

thanks,
shawnj
Last edited by shawnj; 11-27-2008 at 09:09 AM.
shawnj is offline  
Reply With Quote
Old 05-08-2009, 12:45 PM   #6
dbw451
Member
 
Join Date: Jun 2008
Posts: 57
Thanks: 0
Thanked 1 time in 1 post
Default

I've bumped into this serialization problem while saving templates several times now, so I figured if I posted a solution reference, I can google and find it quicker next time.

Basically any indicator class variable that you want to make public should be declared in the Properties region similar to how Plots are exposed. For Ninja series variables, the format is:

[Browsable(false)]
[XmlIgnore()]
public DataSeries Variable
{
get { return dsVariable; }
}

where "dsVariable" is a private DataSeries variable used in the indicator and "Variable" is the public DataSeries that can be accessed by other indicators and strategies. The above format also works for BoolSeries variables. For other C# data types, the format in the Properties region is:

[Browsable(false)]
[XmlIgnore()]
public double DoubleVariable
{
get { Update(); return doubleVariable; }
}

where "doubleVariable" is a private double variable used in the indicator and "DoubleVariable" is the public variable that can be accessed in other indicators and strategies. The Update method is called to force Ninja to update all the variable values before returning the value.

The reference sample TajTrades mentioned (SampleBoolSeries) has additional information in a complete indicator and can be found here:

http://www.ninjatrader-support2.com/...ead.php?t=4991

Regards,

David
dbw451 is offline  
Reply With Quote
Old 05-10-2009, 08:17 AM   #7
astra
Senior Member
 
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
Default

dbw451 (and others),

Thank you very much for taking the time to give such a detailed advice. Just to let you know that helped me to solve my Serialization problem. This advice must be included in the Help file.

Thanks
astra is offline  
Reply With Quote
Old 05-11-2009, 04:07 PM   #8
dbw451
Member
 
Join Date: Jun 2008
Posts: 57
Thanks: 0
Thanked 1 time in 1 post
Default

astra,

You're welcome and thanks for the feedback. I suggest that you pay-it-forward. If you solve a Ninja issue or can clarify a solution in the future that you think would benefit others, take a few minutes and document your issue and solution for the benefit of the Ninja community.

Best Regards,

David
dbw451
dbw451 is offline  
Reply With Quote
Old 05-21-2009, 08:22 AM   #9
dave_b_quickc
Junior Member
 
Join Date: Mar 2009
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default indicator can't be serialized

I'm having the same problem: I have a simple indicator with 2 public BoolSeries, and when I try to save a chart template with this indicator on it the error message pops up about

"indicator can't be serialized, refer [to non-existent] help on serializing indicators"

The error is related to my 2 public boolseries objects, because if I remove them it doesn't give the error. Both boolseries are declared in the variables, initialize, and properties sections according to the examples. The boolseries values are accessible from other indicators even though they generate the serialization error when I try to save a chart template.

Any more ideas?
dave_b_quickc is offline  
Reply With Quote
Old 05-21-2009, 08:29 AM   #10
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

Please see this reference sample on how to expose them properly: http://www.ninjatrader-support2.com/...ead.php?t=4991
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-21-2009, 08:35 AM   #11
dbw451
Member
 
Join Date: Jun 2008
Posts: 57
Thanks: 0
Thanked 1 time in 1 post
Default

The BoolSeries used in your code should be declared as private and only the BoolSeries declared in the Properties section should be public. Whenever I experience the problem, it's because I declared public variables in the Variables section.

Regards,

David
dbw451
dbw451 is offline  
Reply With Quote
The following user says thank you to dbw451 for this post:
Old 05-21-2009, 08:52 AM   #12
dave_b_quickc
Junior Member
 
Join Date: Mar 2009
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
Default thanks!

Thanks dbw, that was it. I had declared the boolseries as public in the variables. I changed it to private and issue is resolved! NT please put dbw on the payroll.
dave_b_quickc is offline  
Reply With Quote
Old 09-14-2009, 04:17 PM   #13
Harry
Senior Member
 
Join Date: Oct 2007
Posts: 1,862
Thanks: 16
Thanked 98 times in 81 posts
Default Serialization Errors

When backing up my workspace, I sometimes get the message indicator XYZ cannot be serialized. Today I had the problem several times, and it just is a game of try and error.

The indicator that causes the problem does not include any TimeSeries other than standard plots, so there is no particular code that could cause the problem. I also downloaded and read the sample files referred to by Josh below, but I cannot find anything wrong at all.

The error occurs when the indicator is applied to one of the charts and is definitely not reproducible. Sometimes the backup works out smoothly and sometimes I get the error message.

Is this one of the the NT database demons at work, or is there anything that I can do to avoid this? Thank you for your help.
Harry is offline  
Reply With Quote
Old 09-15-2009, 04:12 AM   #14
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,558
Thanks: 261
Thanked 1,015 times in 996 posts
Default

Harry, are those indicators embedded in any workspace / template files? Then please try creating a fresh set of files and recheck the issue.
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 09-15-2009, 06:18 AM   #15
max-td
Senior Member
 
Join Date: Feb 2008
Posts: 177
Thanks: 0
Thanked 0 times in 0 posts
Default

yep Harry, this is one of the NT demons at work
i also know this behavior -
Sometimes the "save workplace" works out smoothly and sometimes I get the error message+ its definitely not reproducible.
its not often - and its definitely not a fact of a special indicator or a bad coded indie.
max-td 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
chart load error historical data error Mike_32 Charting 4 11-20-2008 07:24 AM
Serialization error ct Strategy Development 1 09-12-2008 02:32 PM
Error on loading chart data: Native error 14 CJ888 Charting 8 07-20-2006 10:16 PM


All times are GMT -6. The time now is 02:40 AM.