Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Indicator Development

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

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 04-21-2017, 07:03 AM   #1
ku8az
Junior Member
 
Join Date: Sep 2011
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
Default Custom object type property for indicator - errors with "Clone()"

Hello,
I have a following issue with property which is of my custom type (some class with its own properties - I have its custom converter created, it could be serialized into workspace file like a charm).
When I have used this property in indicator, I'm not able to preserve this indicator for example when data provider is connected. Indicator goes away with an error this property couldn't be loaded and/or implementation has changed. Which is a bullshit, of course.
I found somewhere in here, the indicator's "Clone()" implementation is one big mess where a new instance is created using parameterless contructor and after then all available properties are just copied. Which is something really, really bad.
However, I think this causes my issue and I don't know how to handle this correctly.

I have tried also to override a Clone() method to handle this property correctly but I wasn't succesful. Maybe because of the fact, I use in my indicator some (not public) calculation engine class which takes the indicator itself in its constructor parameter. This means, this object can't be created during indicator cloning process as its property is unavailable and it doesn't use parameterless contructor as it has none.

Could you please help me how can I solve this issue?
ku8az is offline  
Reply With Quote
Old 04-21-2017, 07:36 AM   #2
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 10,319
Thanks: 744
Thanked 1,743 times in 1,679 posts
Default

Hello ku8az,

Thank you for your post.

I would need to understand the full case before I could point you in the right direction here.

Can you provide the full error message from your indicator when you connect to your provider?

How are you serializing the property? Can you provide an example of the property as well as the custom converter used?

I look forward to your response.
NinjaTrader_PatrickH is offline  
Reply With Quote
Old 04-21-2017, 08:01 AM   #3
ku8az
Junior Member
 
Join Date: Sep 2011
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
Default

Hi Patrick,
I'd put a message and code samples here after I'll get to my computer. But I think it was something like:

2017-04-20 15:10:45:048 ERROR: Error on getting/setting property 'SessionSettings' for NinjaScript 'MyIndicator': Exception has been thrown by the target of an invocation.
2017-04-20 15:10:45:051 ERROR: Unable to create instance of NinjaScript 'MyIndicator'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.InvalidOperationException: 'DrawHorizontalGridLines' cannot be set from this state. Please see the Help Guide article on 'DrawHorizontalGridLines' for more information. at NinjaTrader.NinjaScript.IndicatorBase.set_DrawHori zontalGridLines(Boolean value) at NinjaTrader.NinjaScript.IndicatorBase.CopyTo(Ninja Script ninjaScript) at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Co pyTo(NinjaScript ninjaScript) at NinjaTrader.NinjaScript.NinjaScript.Clone()

But I really neither have any usage of DrawHorizontalGridLines property not have some special usage of anything in SetDefaults state (just setting of some default indicator properties values).

I don't have any explicit serializer for my class, just [XmlElement] or [XmlIgnore] attributes for all public properties which are of course public for both get and set.
ku8az is offline  
Reply With Quote
Old 04-21-2017, 08:25 AM   #4
ku8az
Junior Member
 
Join Date: Sep 2011
Posts: 13
Thanks: 1
Thanked 0 times in 0 posts
Default

I see, this is quite similar issue as it was stated by Harry in http://ninjatrader.com/support/forum...ad.php?t=93074
ku8az is offline  
Reply With Quote
Old 04-25-2017, 12:27 PM   #5
NinjaTrader_PatrickH
NinjaTrader Customer Service
 
NinjaTrader_PatrickH's Avatar
 
Join Date: Jul 2011
Location: Denver, CO
Posts: 10,319
Thanks: 744
Thanked 1,743 times in 1,679 posts
Default

Hello ku8az,

Thank you for your patience.

Would you be able to provide the details below?

Can you provide the full error message from your indicator when you connect to your provider?

How are you serializing the property? Can you provide an example of the property as well as the custom converter used?

I look forward to your response.
NinjaTrader_PatrickH 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
Editable "custom tag" property for each chart/window (for use with virtual desktops) betaride Suggestions And Feedback 12 08-25-2015 03:52 PM
"Attach To" property for indicator drawn objects Turtle Trader Indicator Development 13 06-04-2015 03:37 PM
"custom ninjascript files on computer that have programming errors" mdblythe Platform Technical Support 4 10-07-2013 12:41 AM
"Type" or "Namespace" HOTKEY don't exist Pcomm69 Strategy Development 6 07-09-2013 09:00 AM
Property "Historical" not passed to referenced indicator poseidon_sthlm Indicator Development 12 09-28-2011 05:23 AM


All times are GMT -6. The time now is 01:05 PM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.