Announcement

Collapse
No announcement yet.

Scoping/Lifecyle of Variables

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

  • Scoping/Lifecyle of Variables

    Hey everyone,

    I've written a script that will plot profit targets when I double click on a bar in my screen.

    Everything works great, but there is one thing that I would like to address.

    When I switch time frames the data is no longer displayed. It's obvious why this is happening and it is because the screen is being re-drawn.

    Currently I maintain an associative array which maintains which bars should have this feature active.

    What I would like to know is how scoping works with EFS, at what point in time would this variable be lost? When I switch a timeframe and the page is redrawn are these variables lost or still maintained? Are global variables kept across these switches?

    Also, is there a means to detect when the screen is being redrawn? Would I be looking for the BARSTATE_ALLBARS flag being set as the current bar state?

    I appreciate any info.

  • #2
    Re: Scoping/Lifecyle of Variables

    Hi davewolfs,

    when you load a new timeframe, the global variables relative to your chart are removed. Perform a forum search with this query Variable* AND scope* and my user name. There are several threads on variable scope that should explain the behavior you are seeing.

    If you exclude my user name, there are a number of additional explanatory threads that may help you as well.

    Take a look at the setGlobalValue() and setGlobalValue() functions as well. They may be what you need as they will remain for as long as you have eSignal open. An example efs on these functions (EFS Formula : getGlobalValue setGlobalValue testing.efs) is attached.



    Originally posted by davewolfs
    Hey everyone,

    I've written a script that will plot profit targets when I double click on a bar in my screen.

    Everything works great, but there is one thing that I would like to address.

    When I switch time frames the data is no longer displayed. It's obvious why this is happening and it is because the screen is being re-drawn.

    Currently I maintain an associative array which maintains which bars should have this feature active.

    What I would like to know is how scoping works with EFS, at what point in time would this variable be lost? When I switch a timeframe and the page is redrawn are these variables lost or still maintained? Are global variables kept across these switches?

    Also, is there a means to detect when the screen is being redrawn? Would I be looking for the BARSTATE_ALLBARS flag being set as the current bar state?

    I appreciate any info.
    Attached Files

    Comment

    Working...
    X