Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Time span values not saved when restarting
Collapse
X
-
Hello Conceptzx,
Thank you for reaching out.
Is the automated strategy you are working with, a strategy coded by yourself using the Strategy Builder, or was it acquired from a 3rd party?
If it is your own coded strategy, please contact our engineering team at
[email protected]
and they will be able to guide you in this matter.
If it is a 3rd party strategy, you would want to contact the developer for assistance with their software.
Please let us know if you have any other questions.Erick P.NinjaTrader Customer Service
-
Originally posted by Conceptzx View PostIt's coded by myself. Is there a way I can retain the settings, or at least get them to go back to what's defined as default within the strategy?
I have moved this thread to the Strategy Development topic in the forum rather than Platform Technical Support. In the future, if you are requesting NinjaScript support for scripts that you have developed, please be sure to post in one of the development topics for the most timely and accurate assistance. Thank you for your understanding.
With that said, I suspect there is an issue happening with the serialization of your TimeSpan inputs. A TimeSpan object may not be serialized normally, so you must make some changes in the Properties region of your script to ensure the values will be saved and restored properly from either the default values within State.SetDefaults or a saved template of the strategy/workspace. First, you must include the XmlIgnore attribute:
Then, you must use a simple type with the NinjaScriptProperty attribute. The final example on this page demonstrates serialization of a TimeSpan input:
This page covers serialization of brush colors that are user inputs, though the same ideas apply when using other object types that may not be serialized normally like TimeSpans:
Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
Comment
-
Originally posted by Conceptzx View PostSo something like this?
Code:[XmlIgnore] [Display(Name = "Trade End Time HH:mm:ss", Order = 2003, GroupName = "02.0. Time")] public TimeSpan TradeEndTime { get { return tradeEndTime; } set { tradeEndTime = value; } }
Code:[XmlIgnore] // cannot serialize type of TimeSpan, use the BeginTimeSpanSerialize object to persist properties [Browsable(false)] // prevents this property from showing up on the UI public TimeSpan BeginTimeSpan { get; set; } // users will configure this "string" as the TimeSpan which will be set as a TimeSpan object used in data processing [NinjaScriptProperty] [Display(Name = "Begin TimeSpan", GroupName = "NinjaScriptStrategyParameters", Order = 1)] public string BeginTimeSpanSerialize { get { return BeginTimeSpan.ToString(); } set { BeginTimeSpan = TimeSpan.Parse(value); } }
Emily C.NinjaTrader Customer Service
Comment
-
Originally posted by Conceptzx View PostDo you have an example script that contains this?
The way you showed would require me to change the time span definitions to strings? Is there a better method for defining time frames?
The same idea behind serializing brushes, which can not be saved as-is into an XML document, applies to serializing TimeSpan objects and other objects that are not a simple type which saves into an XML file without issues.
Thank you for your time and patience.Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Rraannddyy, 09-15-2021, 06:14 PM
|
6 responses
1,012 views
0 likes
|
Last Post
![]()
by MiCe1999
Today, 10:04 AM
|
||
Started by algospoke, 02-20-2025, 08:12 PM
|
9 responses
100 views
0 likes
|
Last Post
![]()
by MiCe1999
Today, 09:41 AM
|
||
Started by michelz, 02-18-2025, 08:30 AM
|
30 responses
975 views
0 likes
|
Last Post
![]()
by michelz
Today, 09:13 AM
|
||
Started by mw_futures, Today, 05:26 AM
|
3 responses
20 views
0 likes
|
Last Post
|
||
Started by Adamel, 04-17-2025, 03:47 PM
|
6 responses
51 views
0 likes
|
Last Post
|
Comment