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

persistent variables

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

    persistent variables

    Is there a way to create variables that will persist after a "reload ninjascript" or after a "reload historical data" or timescale change, etc.
    I'm currently using the UI properties to store these types of variables but that clutters up the UI and I'm looking for a better way to do this.
    Or, if there's a way to suppress the properties from showing up in the UI - without using [Browsable(false)] since that also keeps the variables from being stored persistently.
    Thanks

    #2
    Hello dtl-saw,

    Thank you for the question.

    Is the variable a run-time calculated value or is this some constant value need but not necessarily required in the UI?

    Can you provide an example of how the variable is being used and if you are setting it in your logic? That would be helpful to explore options.

    Generally the public properties are used for storing some option that the user sets, that is generally associated with the OnStateChange/SetDefaults and the charts template/workspace system. For calculated values or things that get set when OnBarUpdate runs that usually requires different methods of storing the data. Depending on what type of data/how frequently it needs set there are various options.

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

    Comment


      #3
      thanks for the response so fast.
      I'm storing chartpoints that I generate using mouse clicks - maybe 4 to 10 of them and then making calculations based off the stored chartpoint values. I don't want the chartpoint values to change during operation unless I change them programmatically. I just need the chartpoints to survive a recalc phase.
      And this is for an indicator - not a drawing tool.
      By the way, is there a way to get the drawing tool persistent values for an indicator -- other words the drawings are able to remember their chartpoints even after program is restarted so is there a way to have that functionality in an indicator?
      thanks again

      Comment


        #4
        Hello dtl-saw,

        Thanks for the additional details.

        In that situation you would likely need to serialize the chart points object yourself when the script terminates to make sure it saves the data. If you don't want to do what you currently are with the property that would be the alternative. This can be messy because you would need a file for each chart and specific names so I wouldn't necessarily have a suggestion on how to approach that, you would likely need to fit that toward your use case and how it will be used.

        For the drawing objects, that would also relate to its public properties. The existing objects save by using the Anchor system however some of those objects have other properties like the gann fan which are saved. The GannFan is likely the closest to what you are describing because it uses a collection of levels. You may be able to do something similar to save your chart points, or create a collection the object saves. That will still show up in the drawing tools properties however it wouldn't show up in your indicators.



        I look forward to being of further assistance.

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Kaledus, Today, 01:29 PM
        0 responses
        3 views
        0 likes
        Last Post Kaledus
        by Kaledus
         
        Started by PaulMohn, Today, 12:36 PM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by yertle, Yesterday, 08:38 AM
        8 responses
        37 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by rdtdale, Today, 01:02 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by alifarahani, Today, 09:40 AM
        3 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X