Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

very frustrating: Templates not saving, no errors

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

    very frustrating: Templates not saving, no errors

    I seem to regularly have this incident and it's a PITA to debug. When the strategy analyzer runs into a value it has some problem with (even if the compiler does not), the template wills save, as 1KB looking like this:

    <?xml version="1.0" encoding="utf-8"?>
    <StrategyTemplate>
    <StrategyType>NinjaTrader.NinjaScript.Strategies .O rganizedStrategy.General</StrategyType>
    <Strategy />
    </StrategyTemplate>​

    I have to go through and start commenting out sections of code until it saves, typically it's a variable that compiles and even works - but for some reason breaks the strategy analyzer saving mechanism. Does anyone else have this?

    #2
    Hello Skifree,

    May I have an export of a reduced test script that just adds the property that causes the behavior?

    To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
    1. Click Tools -> Export -> NinjaScript Add-on...
    2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
    3. Click the 'Export' button
    4. Enter the script name in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message
    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
    Below is a link to the help guide on Exporting NinjaScripts.


    Once exported, please attach the file as an attachment to your reply.​
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      It's not totally feasible to reduce the code, but I believe it's due to the declaration of a custom indicator. Everything saves when i remove it.

      namespace NinjaTrader.NinjaScript.Strategies.OrganizedStrate gy
      {
      public partial class MainStrategy : Strategy
      {
      ​// other code...
      public ShadowsMA ShadowsMA1;

      // other code...

      else if (State == State.DataLoaded)
      {
      ShadowsMA1 = ShadowsMA(ShadowsMAPeriod,ShadowsMAPeriod_Smooth,S hadowsMAPeriod_volume);
      AddChartIndicator(ShadowsMA1);​
      }
      }



      ShadowsMA indicator uses these values:

      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class ShadowsMA : Indicator
      {
      private double alpha; // Smoothing factor used in EMA calculation
      private double decayFactor = 0.5; // Decay factor when the current wick is smaller than the previous

      // Exposing these as public so they can be accessed like ShadowsMA.UpperWick[0]
      public Series<double> UpperWick { get; private set; }
      public Series<double> LowerWick { get; private set; }

      // indicator code...

      [NinjaScriptProperty]
      [Range(1, int.MaxValue)]
      [Display(Name = "PeriodInput", Order = 1, GroupName = "Parameters")]
      public int PeriodInput { get; set; }

      [NinjaScriptProperty]
      [Range(1, int.MaxValue)]
      [Display(Name = "SmoothingPeriod", Order = 2, GroupName = "Parameters")]
      public int SmoothingPeriod { get; set; }

      [NinjaScriptProperty]
      [Range(1, int.MaxValue)]
      [Display(Name = "VolumeFilterMin", Order = 3, GroupName = "Parameters")]
      public int VolumeFilterMin { get; set; }
      }​​

      Comment


        #4
        Hello Skifree,

        May I confirm you are using the XmlIgnore attribute on all public variables that are not string, double, int, bool, stroke, or enum?
        This includes the public Series<double> objects.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          That resolved it - why is there no error when saving a template for something like this?

          Comment


            #6
            Hello Skifree,

            There typically are errors that appear on the Log tab of the Control Center when saving an xml file of a script that has improper public properties/serialization.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            65 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            139 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            75 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X