Is it possible to override the default object serialization ? I looking into providing my own serialization strategies without the use of code attributes.
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Custom serialization
Collapse
X
-
Hello,
Thank you for the post.
You could certainly use C# to serialize an object as you want, you can also prevent properties from being serialized using the [XmlIgnore()] attribute on any properties that should not be serialized. A strategy by default will be serialized if it is left in the workspace as this is needed to reapply it later. You cannot directly disable this but you can disable any custom properties you create and then create logic to save as you wish.
In this situation, you would likely need to wait for a later state like DataLoaded to set a boolean value to know the script was in fact started and applied, then later in State.Terminated check if the bool was set and then serialize your properties or objects in a way you want.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
-
>A strategy by default will be serialized if it is left in the workspace as this is needed to reapply it later
this sounds like if I remove the strategy from the workspace it will not be serialized? does it make sense? and if yes would it be possible to custom deserialize it again and add it to the workspace next time is loaded?
Comment
-
Hello,
If you remove the strategy, it would not reappear the next time you load the workspace or platform. There are no programmatic ways to remove or apply strategies at this time. If you are trying to have it reappear when you start the platform, it would not make sense to remove it.
If you can provide some detail on what you are trying to do specifically, potentially I could recommend other ideas.
If you are trying to create some form of a template loading system to your strategy you can, but the default way the platform handles strategies cannot be changed. You would instead need to use attribute tags to prevent items that should not be serialized from being saved. This is the [XmlIgnore] attribute.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by mmenigma, Yesterday, 03:25 PM
|
1 response
11 views
0 likes
|
Last Post Today, 06:09 AM | ||
Started by kujista, Today, 05:44 AM
|
0 responses
6 views
0 likes
|
Last Post
by kujista
Today, 05:44 AM
|
||
Started by ZenCortexCLICK, Today, 04:58 AM
|
0 responses
9 views
0 likes
|
Last Post Today, 04:58 AM | ||
Started by sidlercom80, 10-28-2023, 08:49 AM
|
172 responses
2,281 views
0 likes
|
Last Post
by sidlercom80
Today, 04:40 AM
|
||
Started by Irukandji, Yesterday, 02:53 AM
|
2 responses
18 views
0 likes
|
Last Post
by Irukandji
Today, 03:55 AM
|
Comment