Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Variable to retain its value

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

    Variable to retain its value

    Hi,

    I create a variable 'show', then by clicking on the chart I cause the variable to change from 'true' to 'false' and back again.

    The problem I'm having is that when I add a new (different) indicator to the chart, my first indicator seems to 'reset' and the 'show' variable goes back to its default value. I want it to retain whatever value it had on the last click, even if I add or remove other indicators from the chart.

    I tried making the variable 'static' but that then shares the variable between all charts with this indicator, which I specifically don't want.

    I'd appreciate if someone could point me in the right direction.

    Thanks

    #2
    Hello bubblegum,

    Thank you for the post.

    To do what you are asking you would need to write that data to file or save it in some way before your script terminate and then re load it when your script starts.

    When applying a new different script to the chart that will cause all items to reload so what you are wanting to do is not something which normally happens. The only time values are explicitly saved would be with a public property when saving a template or workspace, the other variables your script calculates while running are not saved. As you noted static would not work here because that is for the type and not for the instance so all scripts would then share this value.

    Another way which may be possible would be to use code similar to the DrawingToolTile indicator and its CopyTo override. This is not a documented override but can be used to copy values from one instance to another.



    I look forward to being of further assistance.

    Comment


      #3
      Thank you. CopyTo appears to do what I want. But I can't for the life of me get it to work in my indicator!

      Comment


        #4
        Hello bubblegum,

        Are you using it in a similar way to the drawing tool tile indicator? There is no documentation for this override so the only way I could suggest trying to use it would be in the same general way as that indicator. If you are using it in other ways it may not work.

        If you have a sample of what you tried that you can post that would additionally be helpful.

        I look forward to being of further assistance.

        Comment


          #5
          Actually, it works perfectly!! Thank you. It was just me being tired last night, but now it's doing exactly what I want. Cheers.

          Comment


            #6
            What it does do is cause the chart to refresh the screen every time I add or remove an indicator. The DrawingToolTile indicator doesn't appear to do that, so I guess it's turning the display off, or something like that. I'll look in more detail later.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            557 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X