Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to Serialize Dictionary Running Live

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Unable to Serialize Dictionary Running Live

    Hello, I am trying to run a strategy using a dictionary that is of string and custom indicator. It works great in back tests, but I get this serialization error when trying to run it live.

    Error on executing DB command: System.InvalidOperationException: There was an error reflecting type 'NinjaTrader.NinjaScript.Strategies.T1V1S1V1FU'. ---> System.NotSupportedException: Cannot serialize member NinjaTrader.NinjaScript.Strategies.T1V1S1V1FU.Vari ablesDict of type System.Collections.Generic.Dictionary`2[[System.String mscorlib Version=4.0.0.0 Culture=neutral PublicKeyToken=b77a5c561934e089][NinjaTrader.NinjaScript.Indicators.ApolloAssetVari ables 0e14b8840c1d45c7a87f3e57b9425573 Version=8.0.26.0 Culture=neutral PublicKeyToken=null]] because it implements IDictionary. at System.Xml.Serialization.TypeScope.GetDefaultIndex er(Type type String memberInfo) at System.Xml.Serialization.TypeScope.ImportTypeDesc( Type type MemberInfo memberInfo Boolean directReference) at System.Xml.Serialization.TypeScope.GetTypeDesc(Typ e type MemberInfo source Boolean directReference Boolean throwOnError) at System.Xml.Serialization.StructModel.GetPropertyMo del(PropertyInfo propertyInfo) at System.Xml.Serialization.StructModel.GetFieldModel (MemberInfo memberInfo) at System.Xml.Serialization.XmlReflectionImporter.Ini tializeStructMembers(StructMapping mapping StructModel model Boolean openModel String typeName RecursionLimiter limiter) at System.Xml.Serialization.XmlReflectionImporter.Imp ortStructLikeMapping(StructModel model String ns Boolean openModel XmlAttributes a RecursionLimiter limiter) at System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel model String ns ImportContext context String dataType XmlAttributes a Boolean repeats Boolean openModel RecursionLimiter limiter) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(TypeModel model String ns ImportContext context String dataType XmlAttributes a Boolean repeats Boolean openModel RecursionLimiter limiter) at System.Xml.Serialization.XmlReflectionImporter.Imp ortElement(TypeModel model XmlRootAttribute root String defaultNamespace RecursionLimiter limiter) at System.Xml.Serialization.XmlReflectionImporter.Imp ortTypeMapping(Type type XmlRootAttribute root String defaultNamespace) at System.Xml.Serialization.XmlSerializer..ctor(Type type String defaultNamespace) at NinjaTrader.NinjaScript.StrategyBase.ToXml() at NinjaTrader.NinjaScript.StrategyBase.DbAdd() at NinjaTrader.Cbi.DB.DBThread(),

    The custom indicator is basically just a new blank indicator with public properties I am using as variables. The reason I threw these properties in an indicator was because in NT can't serialize new files that aren't a strategy or an indicator(at leased that's the impression I've been given).

    Basically what I'm using this dictionary for is running multiple assets in the same strategy. Each item in the dictionary represents the variables for an asset. Using a dictionary like this is pretty crucial for the strategy, although if I am not able to use a dictionary I can probably get something else figured out.

    I have already tried repairing the DB as well.

    Any help would be appreciated!

    Thanks,

    -Parker

    #2
    Hello Parker,

    Unfortunately, Dictionaries cannot be public inputs. These will need to be private (access modifier).

    That said, for any types that can be properties, if these are public and not serializable, they will need to use the XmlIgnore attribute. (Dictionary would not count as one)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the response! I switched the dictionary property from public to private, and it fixed the issue. Everything works great now!

      Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      91 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      121 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      72 views
      0 likes
      Last Post PaulMohn  
      Working...
      X