Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Property deserialization problem

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

    Property deserialization problem

    Hi

    I've created a custom class WeekTimeRange and added property to the strategy:
    public WeekTimeRange[] WeekTimeSchedule. I verified that the property's data properly serializes and deserializes in/out from the strategy template xml file.
    I haven't created any custom serialization/deserialization functionality.

    Now, when I compile new version of my strategy and enable the existing strategy in the strartegy tab, I get an error in the Output window:
    **NT** Error on getting/setting property 'WeekTimeSchedule' for strategy : Object of type '[Commoneo.Order.WeekTimeRange]' cannot be converted to type '[Commoneo.Order.WeekTimeRange]'.

    The strategy doesn't start. I found out that this is because of the different versions of the strategy: the preconfigured strategy and the latest that they are referring to. When I, however, open up strategy for parameters editing in the strategy tab and click OK, then there is no such problem: no error and the strategy can start. Note, that the class Commoneo.Order.WeekTimeRange have not been changed in the newer version of the strategy.

    I have two questions regarding to this issue:
    1. Why is preset in the Strategy tab is still referring the old version of the strategy? The strategy is not running when I recompile it.
    2. Is there any way to implement tolerant version serialization for the property with custom class type?

    private List<WeekTimeRange> weekTimeSchedule = null;
    [Category("Parameters")]
    public WeekTimeRange[] WeekTimeSchedule
    {
    get { return this.weekTimeSchedule != null ? this.weekTimeSchedule.ToArray() : null; }
    set
    {
    if (value == null)
    this.weekTimeSchedule = null;
    else
    this.weekTimeSchedule = new List<WeekTimeRange>(value);
    }
    }

    public class WeekTimeRange
    {


    public DayOfWeek DayOfWeek { get; set; }

    [TypeConverter(typeof(StringToTimeConverter))]
    public DateTime Time { get; set; }


    public WeekTimeRange()
    {
    //..
    }

    public WeekTimeRange(DayOfWeek dayOfWeek, DateTime time)
    {
    //..
    }

    public override string ToString()
    {
    return string.Format(
    this.DayOfWeek.ToString() + ", " + this.Time.ToString(StringToTimeConverter.TimeForma t);

    }
    }

    #2
    Originally posted by corrado View Post
    Hi

    I've created a custom class WeekTimeRange and added property to the strategy:
    public WeekTimeRange[] WeekTimeSchedule. I verified that the property's data properly serializes and deserializes in/out from the strategy template xml file.
    I haven't created any custom serialization/deserialization functionality.

    Now, when I compile new version of my strategy and enable the existing strategy in the strartegy tab, I get an error in the Output window:
    **NT** Error on getting/setting property 'WeekTimeSchedule' for strategy : Object of type '[Commoneo.Order.WeekTimeRange]' cannot be converted to type '[Commoneo.Order.WeekTimeRange]'.

    The strategy doesn't start. I found out that this is because of the different versions of the strategy: the preconfigured strategy and the latest that they are referring to. When I, however, open up strategy for parameters editing in the strategy tab and click OK, then there is no such problem: no error and the strategy can start. Note, that the class Commoneo.Order.WeekTimeRange have not been changed in the newer version of the strategy.

    I have two questions regarding to this issue:
    1. Why is preset in the Strategy tab is still referring the old version of the strategy? The strategy is not running when I recompile it.
    2. Is there any way to implement tolerant version serialization for the property with custom class type?

    private List<WeekTimeRange> weekTimeSchedule = null;
    [Category("Parameters")]
    public WeekTimeRange[] WeekTimeSchedule
    {
    get { return this.weekTimeSchedule != null ? this.weekTimeSchedule.ToArray() : null; }
    set
    {
    if (value == null)
    this.weekTimeSchedule = null;
    else
    this.weekTimeSchedule = new List<WeekTimeRange>(value);
    }
    }

    public class WeekTimeRange
    {


    public DayOfWeek DayOfWeek { get; set; }

    [TypeConverter(typeof(StringToTimeConverter))]
    public DateTime Time { get; set; }


    public WeekTimeRange()
    {
    //..
    }

    public WeekTimeRange(DayOfWeek dayOfWeek, DateTime time)
    {
    //..
    }

    public override string ToString()
    {
    return string.Format(
    this.DayOfWeek.ToString() + ", " + this.Time.ToString(StringToTimeConverter.TimeForma t);

    }
    }
    In my experience, this happens when you edit strategy code that is on an open chart and enabled. You will need to restart the strategy.

    Comment


      #3
      koganam,

      In my case the strategy is disabled when I recompile.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      672 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      577 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X