Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	19
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.
    Emily C.NinjaTrader Customer Service

    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.​​
        Emily C.NinjaTrader Customer Service

        Comment


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



          ​​
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by esmall, Today, 07:14 PM
          0 responses
          1 view
          0 likes
          Last Post esmall
          by esmall
           
          Started by Option Whisperer, 05-09-2024, 07:58 PM
          6 responses
          25 views
          0 likes
          Last Post Option Whisperer  
          Started by rayyyu12, Today, 05:38 PM
          0 responses
          12 views
          0 likes
          Last Post rayyyu12  
          Started by xepher101, Yesterday, 12:19 PM
          2 responses
          30 views
          0 likes
          Last Post xepher101  
          Started by thumper57, Today, 04:30 PM
          0 responses
          8 views
          0 likes
          Last Post thumper57  
          Working...
          X