Global Variable ??

Questions about MultiCharts and user contributed studies.
Thomas Mann
Posts: 173
Joined: 25 Aug 2007

Global Variable ??

Postby Thomas Mann » 09 Dec 2008

Hi,
I was wondering if someone could show me a way to create a variable in a signal or indicator and have it load initially the first time then maintain that value until it is changed within the script and not on every bar close.
Thanks

RWDickinson
Posts: 43
Joined: 01 Dec 2008
Has thanked: 2 times
Been thanked: 2 times

Postby RWDickinson » 09 Dec 2008

Sorry, I'm not understanding your question. How is what you described different than having an initial value in an Inputs: statement and then updating it in the script?

Thomas Mann
Posts: 173
Joined: 25 Aug 2007

Postby Thomas Mann » 09 Dec 2008

Hi,
I am pretty sure a script gets initialized on every new bar which means my variables get reset. I want to know how to keep certain variables from changing on each bar so I can maintain a state of the variable the entire time the script is running.
Thanks

RWDickinson
Posts: 43
Joined: 01 Dec 2008
Has thanked: 2 times
Been thanked: 2 times

Postby RWDickinson » 09 Dec 2008

No, initial value is set only once and variable values set by the script are persistent across multiple executions - if code is executed only once per bar (update on every tick is off). If code is 'update on every tick' then the intra-bar values are screwy (IMO) but MC is implementing the EL language, they don't get to make decisions about how the language is designed. See this thread:

http://forum.tssupport.com/viewtopic.php?t=5823


Return to “MultiCharts”