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

Data (property) saving/loading

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

    Data (property) saving/loading

    Hello,

    i dont now how to ask this question correctly. I would like to save data to file when i close NT, and load when i run strategy again. Of course I could write my own code, or the below mentioned example would be good as well:

    I would like to save the last value of MaxDrawDown. I create MaxDD indicator class and store here the value, and attributes of a property will be set like that:
    Code:
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    and will not use [XmlIgnore()] attribute. In this case if close NT and save workspace, theoretically it will save the value of property to xml file of workspace. And restart NT, NT will open my workspace and load automatically the saved value, in this case value of MaxDD.

    Could it be a correct solution, instead of writing own code?

    #2
    Originally posted by tamas View Post
    Could it be a correct solution, instead of writing own code?
    Yes ,

    i did it, it works in my sample. When it loads the workspace, datas are loaded as well.

    One more question: am i right when i use [Browsable(false)] attribute and not use [XmlIgnore()] then xml serialization (to myworkspace.xml) dont work? Can i use it together or none of them?

    Thanks in advance

    Comment


      #3
      These properties work independendly, Tamas. Using [Browsable(false)] exclusively (without XmlIgnore) would save and restore that property with the workspace interface.

      Regards
      Ralph

      Comment


        #4
        Originally posted by Ralph View Post
        These properties work independendly, Tamas. Using [Browsable(false)] exclusively (without XmlIgnore) would save and restore that property with the workspace interface.
        Thanks Raplh, i tought the same that it works independetly, yesterday it trow alert window "Indicator 'NinjaTrader.Indicator.AWMaxDD' could not be serialized. Please refer help for more information on serializing indicators.", thats why i asked, but now it works. I dont know what happened yesterday ...

        Comment


          #5
          I think your problem is related to the data type of AWMaxDD. C# automatically serialises only simple data types like string, int, double, etc. Complex types like Color, structures or classes have to be serialised by the user.

          Regards
          Ralph

          Comment


            #6
            Originally posted by Ralph View Post
            I think your problem is related to the data type of AWMaxDD. C# automatically serialises only simple data types like string, int, double, etc. Complex types like Color, structures or classes have to be serialised by the user.
            thank you Ralph

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by love2code2trade, Yesterday, 01:45 PM
            4 responses
            28 views
            0 likes
            Last Post love2code2trade  
            Started by funk10101, Today, 09:43 PM
            0 responses
            7 views
            0 likes
            Last Post funk10101  
            Started by pkefal, 04-11-2024, 07:39 AM
            11 responses
            37 views
            0 likes
            Last Post jeronymite  
            Started by bill2023, Yesterday, 08:51 AM
            8 responses
            44 views
            0 likes
            Last Post bill2023  
            Started by yertle, Today, 08:38 AM
            6 responses
            26 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Working...
            X