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:	51
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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          20 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          30 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          48 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          38 views
          0 likes
          Last Post CarlTrading  
          Working...
          X