• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 xmanjames, Today, 04:22 PM
        0 responses
        3 views
        0 likes
        Last Post xmanjames  
        Started by McQuac, Today, 03:48 PM
        0 responses
        3 views
        0 likes
        Last Post McQuac
        by McQuac
         
        Started by aviat72, Today, 01:00 PM
        2 responses
        11 views
        0 likes
        Last Post aviat72
        by aviat72
         
        Started by Andrey-Ufa, Today, 12:18 PM
        0 responses
        2 views
        0 likes
        Last Post Andrey-Ufa  
        Started by ben_ocean11, Today, 10:16 AM
        0 responses
        10 views
        0 likes
        Last Post ben_ocean11  
        Working...
        X