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 AaronKoRn, Today, 09:49 PM
          0 responses
          7 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Today, 08:42 PM
          0 responses
          9 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Today, 07:51 PM
          0 responses
          10 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,980 views
          3 likes
          Last Post jhudas88  
          Started by rbeckmann05, Today, 06:48 PM
          0 responses
          9 views
          0 likes
          Last Post rbeckmann05  
          Working...
          X