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

Serialization - no help

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

    Serialization - no help

    I am getting the message

    Indicator ..... could not be serialized.
    Please refer help for more information on serializing indicators.


    Which is fine .... except that I can't find anything about serialization in the help!!

    Sometimes it's just not easy using NT.

    #2
    Sorry for the frustrations Mindset, please see this tip here showing custom serialization of color inputs as an example - http://www.ninjatrader.com/support/f...ead.php?t=4977
    BertrandNinjaTrader Customer Service

    Comment


      #3
      List

      Can't NT give us a list of serializable classes?

      Comment


        #4
        List of Serializable Objects

        I can't give you a complete list. But after an exhaustive search thru the Ninja Classes in v6.5 I discovered the following. Nijja 7.0 may have a few more, but I've not gone looking since it shipped,

        1. Color
        Code:
         
        [FONT=Courier New][SIZE=1][COLOR=black]public [/COLOR][COLOR=red]Color[/COLOR][COLOR=black] PaintColor[/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=1][COLOR=black]{[/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=1][COLOR=black]  get { return paintColor; }[/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=1][COLOR=black]  set { paintColor = value; }[/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=1][COLOR=black]}[/COLOR][/SIZE][/FONT]
         
        [FONT=Courier New][SIZE=1][COLOR=black][Browsable(false)][/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=1][COLOR=black]public string PaintColorSerialize[/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=1][COLOR=black]{[/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=1][COLOR=black]  get { return NinjaTrader.Gui.Design.[COLOR=blue][B]SerializableColor[/B][/COLOR].ToString(paintColor); }[/COLOR][/SIZE][/FONT]
        [COLOR=black][FONT=Courier New][SIZE=1]  set { paintColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }[/SIZE][/FONT][/COLOR]
        [COLOR=black][FONT=Courier New][SIZE=1]}[/SIZE][/FONT][/COLOR]
        2. Font
        Code:
          
        [FONT=Courier New][Browsable(false)][/FONT]
        [FONT=Courier New]public string MyFontSerialize[/FONT]
        [FONT=Courier New]{[/FONT]
        [FONT=Courier New]get { return NinjaTrader.Gui.Design.[COLOR=blue][B]SerializableFont[/B][/COLOR].ToString(textFont); }[/FONT]
        [FONT=Courier New]set { textFont = NinjaTrader.Gui.Design.SerializableFont.FromString(value); }[/FONT]
        [FONT=Courier New]}[/FONT]
         
        [FONT=Courier New][XmlIgnore()][/FONT]
        [FONT=Courier New][Description("Font of Bar Numbers")][/FONT]
        [FONT=Courier New][Gui.Design.DisplayName("Text Font")][/FONT]
        [FONT=Courier New][Category("Parameters - Font")][/FONT]
        [FONT=Courier New]     public System.Drawing.Font TextFont[/FONT]
        [FONT=Courier New]     {[/FONT]
        [FONT=Courier New]         get { return textFont; }[/FONT]
        [FONT=Courier New]         set { textFont = value; }[/FONT]
        [FONT=Courier New]     }[/FONT]
        3. Pen
        Not out of the box but you can roll your own, so it saves Color, DashStyle & width of pen.
        As KBJ has posted an update for v7.0, I refer you to his post.
        http://www.ninjatrader.com/support/forum/showthread.php?p=149047

        4. Filename
        I wrote my own for this, unfortunately the code is too long for this post. I'll split it & do a separate post when I tidy it up.

        5. Roll your own.
        Ninja just nses standard .NET code & standard .NET properts pane. So you will find a ton of stuff on serialization on the MSDN.Microsoft.com site among others.

        I hope this gets you started.
        Dave
        Last edited by David Lean; 05-13-2011, 07:07 AM.

        Comment


          #5
          Serial

          Thanks David - much appreciated. Turned out it was the pen that was causing my serialisation issue - if I declared it as a variable it messed up ; new instance within Plot override it was quite happy

          Comment


            #6
            Interesting, I just created an indicator with 4 PEN parameters. I used the code exactly as is posted on the Ninja site, in the OnBarUpdate() event. It ran fine. So you shouldn't feel compelled ot use the Plot() method if that wasn't part of your original design.

            (In fact I like it better than the serialization routines, I was using in v6.5, so I ditched my code & will use it from now on.)

            Comment


              #7
              Plot

              I override Plot a lot in my indicator so this has been a sort of useful excursion. Thanks for the update.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by George21, Today, 10:07 AM
              0 responses
              5 views
              0 likes
              Last Post George21  
              Started by Stanfillirenfro, Today, 07:23 AM
              8 responses
              23 views
              0 likes
              Last Post Stanfillirenfro  
              Started by DayTradingDEMON, Today, 09:28 AM
              2 responses
              16 views
              0 likes
              Last Post DayTradingDEMON  
              Started by navyguy06, Today, 09:28 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cmtjoancolmenero, Yesterday, 03:58 PM
              8 responses
              32 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X