Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Serialization Bug

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

    Serialization Bug

    I finally nailed down this serialization bug. It looks like the NT coders just like using the List<> and ArrayList data structures .

    Please add serialization for:

    Queue<>, Dictionary<>, SortedDictionary<>, Stack<>, SortedList<>, LinkedList<>


    The following indicator generates a serialization error when you try to save it in a workspace:


    Code:
    using System.Collections;
    using System.Collections.Generic;
    
    namespace NinjaTrader.Indicator
    {
        public class aaaTestSerialize : Indicator
        {
    	//public List<int> FMyThings = new List<int>(); //OK
    	//public ArrayList FMyThings = new ArrayList(); //nongenerics  //OK - of course ;)
    		
    	public Queue<int> FMyThings = new Queue<int>(); //Fails
    	//public Queue FMyThings = new Queue();  //nongenerics //Fails
    	//public Dictionary<string,int> FMyThings = new Dictionary<string,int>(); //Fails
    	//public SortedDictionary<string,int> FMyThings = new SortedDictionary<string,int>(); //Fails
    	//public Stack<int> FMyThings = new Stack<int>(); //Fails
    	//public SortedList<string,int> FMyThings = new SortedList<string,int>(); //Fails
    	//public LinkedList<int> FMyThings = new LinkedList<int>(); //Fails 
    		
            protected override void Initialize()
            {} 
            protected override void OnBarUpdate()
            {} 
        }
    }
    Last edited by shawnj; 12-03-2008, 03:11 PM.

    #2
    Thanks for your suggestion. We'll add it to the list of future considerations.

    Comment


      #3
      with Font variables like input parameters, Serialization doesn't work neither.

      Comment


        #4
        Hi,

        It cannot serialize multidimensional array as well .

        we are using multidimensional arrays all the time.

        This is a real problem

        Please add it

        Comment


          #5
          Hello EmmanuelEv1,

          Thanks for your post and welcome to the NinjaTrader Forums.

          I see you have posted in the NinjaTrader 7 section of the Forums.

          To clarify, what version of NinjaTrader are you using? This could be found in the Control Center > Help > About window.

          Are you using NinjaTrader 7 or NinjaTrader 8 and want to serialize a multi-dimensional array?

          We look forward to assisting further.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Hello

            I am using NT8 and I want to serialize a multi-dimensional array
            Last edited by EmmanuelEv1; 10-19-2024, 07:00 AM.

            Comment


              #7
              Hello EmmanuelEv1,

              Below is a link to a forum post that discusses serializing a few object types and shows the pattern for serializing.


              You will need to create custom logic to convert the multi-dimensional array to a string in the getter, which can be saved to xml, and then convert the saved string back to a multi-dimensional array in the setter.

              With a single-dimensional array I might suggest using String.Join() to join the elements with a delimiter (something like a semi-colon that will not be in the text of the string), and then using <string>.Split() to convert the saved string back to an array.
              Concatenates the elements of a specified array or the members of a collection, using the specified separator between each element or member.

              Returns a string array that contains the substrings in this instance that are delimited by elements of a specified string or Unicode character array.


              However, for a multi-dimensional array this would be more complex.

              Below I am including links to google searches for 'c# multi-dimensional array to string' and 'c# string to multi-dimensional array' which may give you some ideas on how to accomplish this task.

              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thank you very much Chelsea for your answer !

                to convert the multi-dimensional array to a string is an excellent idea ! From this idea, we can work with any array !

                Thank you so much

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                558 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X