Announcement

Collapse
No announcement yet.

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.

    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.

        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.

            Comment


              #7
              Thanks a lot.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              62 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              34 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              50 views
              1 like
              Last Post CaptainJack  
              Started by CarlTrading, 03-30-2026, 11:51 AM
              0 responses
              59 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 03-30-2026, 11:48 AM
              0 responses
              47 views
              0 likes
              Last Post CarlTrading  
              Working...
              X