Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't save indicator into workspace.

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

    Can't save indicator into workspace.

    Hi, NT Team:

    I've written some NT indicators and loaded in the chart and they all works fine.
    However, when I saved and closed the workspace, some indicators can not be saved (some can).
    I checked the log file and only get one line like:

    Could not save indicator 'MP_Indicator:' There was an error reflecting type 'NinjaTrader.NinjaScript.Indicators.MP_MorganTest' .

    Any more detail I can get?
    Otherwise, it's really hard to find the reason I can't save them into workspace.

    Thanks~

    Morgan



    #2
    Hello Morgan0321,

    Thanks for your post.

    This is likely due to a Serialization issue within your script.

    You should make sure that you are applying the [XmlIgnore] property attribute to any public Brush or TimeSpan property in the script.

    Also, ensure that you are serializing any brushes or timespans in the properties section of your script.

    For example, see below.

    Code:
    [XmlIgnore()]
    [Display(Name = "BorderBrush", GroupName = "NinjaScriptParameters", Order = 0)]
    public Brush BorderBrush
    { get; set; }
    
    // Serialize our Color object
    [Browsable(false)]
    public string BorderBrushSerialize
    {
    get { return Serialize.BrushToString(BorderBrush); }
    set { BorderBrush = Serialize.StringToBrush(value); }
    }
    See the help guide documentation and reference sample demonstrating this.
    SampleBrushInput: https://ninjatrader.com/support/help...lor_inputs.htm
    Working with Brushes: https://ninjatrader.com/support/help...tsub=xmlignore
    NinjaScriptPropertyAttribute: https://ninjatrader.com/support/help...yattribute.htm

    Let us know if we may assist further
    Last edited by NinjaTrader_BrandonH; 06-23-2022, 07:36 AM.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi, BrandonH:

      Thanks for your reply.
      I tried to comment out
      some variables in my indicator and find the followig points cause this issue:

      public Series<double> TempOpen;
      public Series<double> TempHigh;
      public Series<double> TempLow;
      public Series<double> TempClose;

      When I comment out them, the workspace can be saved now.
      But I need to use them in the program, how can I use them correctly?

      Thanks~

      Morgan

      Comment


        #4
        Hello Morgan0321,

        Thanks for your note.

        I see that the variables you are referring to are Series<doubles> variables and they are defined as public.

        Series<double> variables are typically defined as private variables, such as private Series<double> mySeriesDouble.

        See this help guide for more information and sample code: https://ninjatrader.com/support/help...t8/seriest.htm

        It could be possible to create public Series<double> variables. If you do, you would need to use [XmlIgnore].

        See the reference sample below for how this could be done: https://ninjatrader.com/support/help...alues_that.htm

        And see this help guide documentation below: XmlIgnore: https://ninjatrader.com/support/help...tsub=xmlignore

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hi, BrandonH:

          Thanks for your suggestion.
          After adding [XMLIgnore] label above the Series variable,
          it can be saved into workspace successfully now.
          Really appreciate your help!


          Morgan

          Comment


            #6
            Originally posted by Morgan0321 View Post
            Hi, BrandonH:

            Thanks for your suggestion.
            After adding [XMLIgnore] label above the Series variable,
            it can be saved into workspace successfully now.
            Really appreciate your help!


            Morgan
            hello Morgan, im from china
            and i use your indicator now~
            appreciation​​

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            57 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            20 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            9 views
            0 likes
            Last Post cre8able  
            Working...
            X