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

Save data programmatically

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

    Save data programmatically

    Hi,

    Is it possible to save data within an indicator programmatically? I want to persistently save some state information (not price data).

    Regards,

    #2
    Hello Halmix,

    Yes that is possible, generally a Public property would be used to save something.

    Would this be a value that the user configures or is this a value the script calculates while it runs?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      The value is calculated by the script while it runs.

      Comment


        #4
        Hello Halmix,

        Thank you for the reply.

        For a calculated value you would need to save that yourself, the most simple way would be to write that data to file and then re load it once the script starts. We have a couple of examples of writing and reading data which you can find here:




        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Is it possible to overwrite and save user properties programmatically instead? Or can these properties only be persistently changed using the user interface?

          Comment


            #6
            Hello Halmix,

            You could technically use a user input for this for a simple type like an int or a bool however that will show up as a selection when you apply the script. If you don't mind that you can just make a standard NinjaScriptProperty:

            [NinjaScriptProperty]
            [Display(Name="Test", Order=1, GroupName="Parameters")]
            public int TestInt
            { get; set; }

            That would be saved with the workspace/templates and through F5 reloads so it could become difficult to track its value depending on what the value needs to be or when it needs set.

            I look forward to being of further assistance.

            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks a lot.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by DT215, 01-14-2023, 07:59 PM
              4 responses
              132 views
              1 like
              Last Post NinjaTrader_BrandonH  
              Started by ETFVoyageur, Yesterday, 12:52 AM
              2 responses
              32 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by Skifree, Yesterday, 02:50 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_Kimberly  
              Started by owen5819, Yesterday, 02:24 PM
              2 responses
              16 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by ETFVoyageur, Yesterday, 10:13 PM
              2 responses
              20 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X