Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Script Error

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

    Script Error

    Hi,

    Today I got an error from a script and it might've been an issue that it was not working as it should. e.g. Did not take profit at set levels.


    Appreciate the help!


    Click image for larger version

Name:	image.png
Views:	49
Size:	187.3 KB
ID:	1291261




    #2
    Hello carlosgutierrez,

    Thank you for your post.

    This error appears to be related to the strategy "TrendCrusherv10" and the property for Period. Is this a strategy that you created or one that was imported from a third party? If it is one that you created, how do you have the property for Period set up in your script? Please provide snippets so we may better understand and assist you.

    I look forward to your reply.

    Comment


      #3
      Here it goes::

      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      // Indicator Settings
      Period = 14;
      Multiplier = 2.618;
      Smooth = 14;​
      }

      if (State == State.Configure)
      {
      AddDataSeries(new BarsPeriod()
      {
      BarsPeriodType = (BarsPeriodType)12345,
      Value = 50,
      Value2 = 1
      }
      );

      AddDataSeries("MNQ 03-24");
      }
      else if (State == State.DataLoaded)
      {
      TrendCrusherIndicator1 = TrendCrusherIndicator(Close, TCSuperTrendMode.ATR, Period, Multiplier, TCMovingAverageType.HMA, Smooth, false, false, false);
      AddChartIndicator(TrendCrusherIndicator1);
      // SetStopLoss("", CalculationMode.Currency, HardStop, false);
      SetTrailStop("", CalculationMode.Ticks, TrailingTicks, false);

      }




      [NinjaScriptProperty]
      [Browsable (false)]
      [Range(1, int.MaxValue)]
      [Display(Name="Period", Order=1, GroupName="TCI Settings")]
      public int Period
      { get; private set; }​
      ​​

      Comment


        #4
        Hello carlosgutierrez,

        Thank you for your reply.

        The error has to do with the use of a private setter; this property requires a public setter for deserialization to be successful. The error message stated, "Cannot deserialize type ____ because it contains a property ____ which has no public setter." Removing the 'private' modifier should resolve this item:

        [NinjaScriptProperty]
        [Browsable (false)]
        [Range(1, int.MaxValue)]
        [Display(Name="Period", Order=1, GroupName="TCI Settings")]
        public int Period
        { get; private set; }​

        vs.

        [NinjaScriptProperty]
        [Browsable (false)]
        [Range(1, int.MaxValue)]
        [Display(Name="Period", Order=1, GroupName="TCI Settings")]
        public int Period
        { get; set; }​


        Please let us know if we may be of further assistance.​​

        Comment


          #5
          This worked perfectly. No errors since the change, thanks!



          ​​
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          52 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          48 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X