Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator could not be serialized

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

    Indicator could not be serialized

    Ninja Folks,

    I created an indicator that compiled with no problems. However, when I tried to Save the Workspace I received the Error "Indicator could not be serialized. Please refer help for more information on serializing indicators". I hit the F1 (F1 and I have become very close friends) key and found nothing to help diagnose this issue.

    Can you point me in the right direction?

    Thanks

    #2
    Hi TAJTrades,

    Is your indicator running on a chart somewhere? Please try removing the indicator from any running instances and see what happens. Then try removing the indicator from NinjaTrader altogether. Backup your code first. See what happens then.

    If you still get the error then it is something with the code. Please upload the code here then we can take a quick glance through at it to see if we see anything out of the ordinary.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      "Is your indicator running on a chart somewhere? Please try removing the indicator from any running instances and see what happens."

      When I removed the indicator and the strategy calling the indicator form the chart the workspace closed with NO error message.

      Here is the situation:
      - Indicator creates 2 DataSeries with values of 0 to 20 (integers, no decimals)
      - Indicator creates Trend Lines on the chart.
      - A Strategy calls the DataSeries for input into the Strategy with the line:
      IndicatorV5(80,1,5,20,40,period1,period2,true).bea rishDivergenceCount[1];

      Indicator results:
      -Trend Lines are drawn as expected
      -DataSeries values created as expected per the Output Window
      - The Strategy is accessing the Indicator DataSeries as it is firing off trades in the Sim101 Account.


      My guess is that I have not defined the DataSeries in a way that Ninja needs to have everything sync and accessible. I have defined the DataSeries as follows:

      #region Variables
      (Other Inputs);

      public DataSeries bullishDivergenceCount; // DataSeries Bullish Divergence;
      public DataSeries bearishDivergenceCount; // DataSeries Bullish Divergence;

      #endregion

      protected override void Initialize()
      {
      CalculateOnBarClose = true;
      Overlay = true;
      PriceTypeSupported = false;

      bullishDivergenceCount = new DataSeries(this);
      bearishDivergenceCount = new DataSeries(this);

      }


      protected override void OnBarUpdate()
      {
      // Lots of code creating DataSeries Values and Trend Lines

      bullishDivergenceCount.Set(Value);
      bearishDivergenceCount.Set(Value); // Value being an integer number assigned to that bar

      }

      #region Properties
      nothing pertaining to the DataSeries
      #endregion


      Have I defined the DataSeries correctly to sync everything and give access to the Strategy?

      Many thanks for your help.

      Comment


        #4
        You should not create public DataSeries like that. Please check out this reference sample on how to expose DataSeries for use in strategies. http://www.ninjatrader-support.com/v...ead.php?t=4991
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh,

          I just opened a fresh chart and put the Indicator on it and then Closed the Work Space. Got the same Error Message.

          I repeated the process this time only putting the Strategy that calls the Indicator and closed the Work Space with the Strategy still attached. Got NO error Message.

          My best guess is that the issue is with the Indicator either with defining the DataSeries or or the .Set command

          Back to the drawing board.

          TJ

          Comment


            #6
            TAJTrades,

            Please start by using exposed properties to access the internal DataSeries objects. The reference sample I posted earlier demonstrates how to do this with a BoolSeries. It is done exactly the same way for a DataSeries.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Its a trick. There's two of them. Half a bottle of Merlot later I realized that SampleBoolSeries.zip has both a Strategy and Indicator in the example.

              All is well. Thanks Josh

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by LeroyO, Today, 04:09 PM
              0 responses
              1 view
              0 likes
              Last Post LeroyO
              by LeroyO
               
              Started by sidlercom80, Today, 04:57 AM
              2 responses
              29 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by Tartagliagroup, Today, 02:11 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by rickyblah12, Today, 01:33 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by rcloutier, Today, 01:17 PM
              4 responses
              14 views
              0 likes
              Last Post rcloutier  
              Working...
              X