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

What does SERIALIZING INDICATORS mean?

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

    What does SERIALIZING INDICATORS mean?

    I just tried to save a workspace that included a version of DM I had written to include a third line instead of just the 2 drawn lines it supplied.
    It compiles and charts OK, but trying to save the workspace gives the error The Indicator DMmine could not be serialized and to look at Help, but I cant find serialized in any search.
    What does it mean?

    #2
    Hello,

    Go back into any indicator and try to compile it. Do you get any errors? Are you on a network server?
    DenNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ben View Post
      Hello,

      Go back into any indicator and try to compile it. Do you get any errors? Are you on a network server?
      Not on a newtwork server, and I've compiled no problem before or since except still withat one indicator I can reprosuce--my only change was to draw 3 lines 20,25,30 instead of the 25, 75 defaults and colors changed too.

      I do use a router, but why this one indicator?
      HTML Code:
      // 
      // Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
      // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
      //
      #region Using declarations
      using System;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.ComponentModel;
      using System.Xml.Serialization;
      using NinjaTrader.Data;
      using NinjaTrader.Gui.Chart;
      #endregion
      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      /// <summary>
      /// Directional Movement (DMmine). This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
      /// </summary>
      [Description("This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.")]
      public class DMmine : Indicator
      {
      #region Variables
      private int period = 14;
      private DataSeries dmPlus;
      private DataSeries dmMinus;
      private DataSeries sumDmPlus;
      private DataSeries sumDmMinus;
      private DataSeries sumTr;
      private DataSeries tr;
      #endregion
      /// <summary>
      /// This method is used to configure the indicator and is called once before any bar data is loaded.
      /// </summary>
      protected override void Initialize()
      {
      Add(new Plot(new Pen(Color.Black, 3), "ADX"));
      Add(new Plot(Color.Green, "+DI"));
      Add(new Plot(Color.Red, "-DI"));
      Add(new Line(Color.Black, 20, "20"));
      Add(new Line(Color.Blue, 25, "25"));
      Add(new Line(Color.Crimson, 30, "30"));
      
      dmPlus = new DataSeries(this);
      dmMinus = new DataSeries(this);
      sumDmPlus = new DataSeries(this);
      sumDmMinus = new DataSeries(this);
      sumTr = new DataSeries(this);
      tr = new DataSeries(this);
      }
      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      double trueRange = High[0] - Low[0];
      if (CurrentBar == 0)
      {
      tr.Set(trueRange);
      dmPlus.Set(0);
      dmMinus.Set(0);
      sumTr.Set(tr[0]);
      sumDmPlus.Set(dmPlus[0]);
      sumDmMinus.Set(dmMinus[0]);
      Value.Set(50);
      }
      else
      {
      tr.Set(Math.Max(Math.Abs(Low[0] - Close[1]), Math.Max(trueRange, Math.Abs(High[0] - Close[1]))));
      dmPlus.Set(High[0] - High[1] > Low[1] - Low[0] ? Math.Max(High[0] - High[1], 0) : 0);
      dmMinus.Set(Low[1] - Low[0] > High[0] - High[1] ? Math.Max(Low[1] - Low[0], 0) : 0);
      if (CurrentBar < Period)
      {
      sumTr.Set(sumTr[1] + tr[0]);
      sumDmPlus.Set(sumDmPlus[1] + dmPlus[0]);
      sumDmMinus.Set(sumDmMinus[1] + dmMinus[0]);
      }
      else
      {
      sumTr.Set(sumTr[1] - sumTr[1] / Period + tr[0]);
      sumDmPlus.Set(sumDmPlus[1] - sumDmPlus[1] / Period + dmPlus[0]);
      sumDmMinus.Set(sumDmMinus[1] - sumDmMinus[1] / Period + dmMinus[0]);
      }
      double diPlus = 100 * (sumTr[0] == 0 ? 0 : sumDmPlus[0] / sumTr[0]);
      double diMinus = 100 * (sumTr[0] == 0 ? 0 : sumDmMinus[0] / sumTr[0]);
      double diff = Math.Abs(diPlus - diMinus);
      double sum = diPlus + diMinus;
      Value.Set(sum == 0 ? 50 : ((Period - 1) * Value[1] + 100 * diff / sum) / Period);
      DiPlus.Set(diPlus);
      DiMinus.Set(diMinus);
      }
      }
      #region Properties
      /// <summary>
      /// </summary>
      [Browsable(false)]
      [XmlIgnore()]
      public DataSeries DiPlus
      {
      get { return Values[1]; }
      }
      /// <summary>
      /// </summary>
      [Browsable(false)]
      [XmlIgnore()]
      public DataSeries DiMinus
      {
      get { return Values[2]; }
      }
      
      /// <summary>
      /// </summary>
      [Description("Numbers of bars used for calculations")]
      [Category("Parameters")]
      public int Period
      {
      get { return period; }
      set { period = Math.Max(1, value); }
      }
       
      #endregion
      }
      }
      #region NinjaScript generated code. Neither change nor remove.
      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      public partial class Indicator : IndicatorBase
      {
      private DMmine[] cacheDMmine = null;
      private static DMmine checkDMmine = new DMmine();
      /// <summary>
      /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
      /// </summary>
      /// <returns></returns>
      public DMmine DMmine(int period)
      {
      return DMmine(Input, period);
      }
      /// <summary>
      /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
      /// </summary>
      /// <returns></returns>
      public DMmine DMmine(Data.IDataSeries input, int period)
      {
      checkDMmine.Period = period;
      period = checkDMmine.Period;
      if (cacheDMmine != null)
      for (int idx = 0; idx < cacheDMmine.Length; idx++)
      if (cacheDMmine[idx].Period == period && cacheDMmine[idx].EqualsInput(input))
      return cacheDMmine[idx];
      DMmine indicator = new DMmine();
      indicator.BarsRequired = BarsRequired;
      indicator.CalculateOnBarClose = CalculateOnBarClose;
      indicator.Input = input;
      indicator.Period = period;
      indicator.SetUp();
      DMmine[] tmp = new DMmine[cacheDMmine == null ? 1 : cacheDMmine.Length + 1];
      if (cacheDMmine != null)
      cacheDMmine.CopyTo(tmp, 0);
      tmp[tmp.Length - 1] = indicator;
      cacheDMmine = tmp;
      Indicators.Add(indicator);
      return indicator;
      }
      }
      }
      // This namespace holds all market analyzer column definitions and is required. Do not change it.
      namespace NinjaTrader.MarketAnalyzer
      {
      public partial class Column : ColumnBase
      {
      /// <summary>
      /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
      /// </summary>
      /// <returns></returns>
      [Gui.Design.WizardCondition("Indicator")]
      public Indicator.DMmine DMmine(int period)
      {
      return _indicator.DMmine(Input, period);
      }
      /// <summary>
      /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
      /// </summary>
      /// <returns></returns>
      public Indicator.DMmine DMmine(Data.IDataSeries input, int period)
      {
      return _indicator.DMmine(input, period);
      }
      }
      }
      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      public partial class Strategy : StrategyBase
      {
      /// <summary>
      /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
      /// </summary>
      /// <returns></returns>
      [Gui.Design.WizardCondition("Indicator")]
      public Indicator.DMmine DMmine(int period)
      {
      return _indicator.DMmine(Input, period);
      }
      /// <summary>
      /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.
      /// </summary>
      /// <returns></returns>
      public Indicator.DMmine DMmine(Data.IDataSeries input, int period)
      {
      if (InInitialize && input == null)
      throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
      return _indicator.DMmine(input, period);
      }
      }
      }
      #endregion

      Comment


        #4
        Have you tried changing both dataseries properties to Values[0] / Values[1]?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Have you tried changing both dataseries properties to Values[0] / Values[1]?
          It saved OK when i did shut down. The onlything I did in between was pull up a minimized FESX chart with the indicator on it also (the other chart was ES). The FESX indicator hadnt been set to calculate on bar close so I reset it that way, and later when I shut down i was ok. Maybe that was it.

          Comment


            #6
            simpletrades, since you have two plots only, you would have Values[0] and Values[1] being used -

            Code:
            [Browsable(false)]
            [XmlIgnore()]
            public DataSeries DiPlus
            {
            get { return Values[0]; }
            }
            /// [COLOR=#000080]<summary>[/COLOR]
            /// [COLOR=#000080]</summary>[/COLOR]
            [Browsable(false)]
            [XmlIgnore()]
            public DataSeries DiMinus
            {
            get { return Values[1]; }
            }
            Please apply those changes and retry.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by geddyisodin, Today, 05:20 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by Max238, Today, 01:28 AM
            3 responses
            33 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by timko, Today, 06:45 AM
            2 responses
            13 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Started by habeebft, Today, 07:27 AM
            0 responses
            6 views
            0 likes
            Last Post habeebft  
            Started by Tim-c, Today, 03:54 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X