![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2005
Location: , ,
Posts: 218
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,558
Thanks: 261
Thanked 1,015 times in 996 posts
|
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!
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2005
Location: , ,
Posts: 218
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Dec 2007
Location: Atlanta
Posts: 281
Thanks: 0
Thanked 4 times in 3 posts
|
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 |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2005
Location: , ,
Posts: 218
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#6 |
|
Member
Join Date: Jun 2008
Posts: 57
Thanks: 0
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#8 |
|
Member
Join Date: Jun 2008
Posts: 57
Thanks: 0
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Mar 2009
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
|
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? |
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Please see this reference sample on how to expose them properly: http://www.ninjatrader-support2.com/...ead.php?t=4991
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Member
Join Date: Jun 2008
Posts: 57
Thanks: 0
Thanked 1 time in 1 post
|
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 |
|
|
|
|
The following user says thank you to dbw451 for this post: |
|
|
|
#12 |
|
Junior Member
Join Date: Mar 2009
Posts: 26
Thanks: 0
Thanked 1 time in 1 post
|
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.
|
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Oct 2007
Posts: 1,862
Thanks: 16
Thanked 98 times in 81 posts
|
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. |
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,558
Thanks: 261
Thanked 1,015 times in 996 posts
|
Harry, are those indicators embedded in any workspace / template files? Then please try creating a fresh set of files and recheck the issue.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Senior Member
Join Date: Feb 2008
Posts: 177
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |