if a variable is initiated inside a Begin / End section of a script and that section never Begins...
Does that variable get initialized?
what value is in that variable if it never gets initialized?
Newb question [SOLVED]
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Newb question
It's not possible to make a variable without also initialising it at the same time.if a variable is initiated inside a Begin / End section of a script and that section never Begins...
Does that variable get initialized?
what value is in that variable if it never gets initialized?
To make a variable we use the `Variable`, `Variables`, `Var`, or `Vars` statement (they are are the same) like this:
Code: Select all
Variables:
chartHigh(0);
If we use `chartHigh` in a `once`-`begin` block, the variable still keeps its zero value.
In comparison with other programming languages, MultiCharts PowerLanguage doesn't have uninitialised variables.
Re: Newb question
Thanks very muchIt's not possible to make a variable without also initialising it at the same time.if a variable is initiated inside a Begin / End section of a script and that section never Begins...
Does that variable get initialized?
what value is in that variable if it never gets initialized?
To make a variable we use the `Variable`, `Variables`, `Var`, or `Vars` statement (they are are the same) like this:
This variable is initialised with a default value of `0`.Code: Select all
Variables: chartHigh(0);
If we use `chartHigh` in a `once`-`begin` block, the variable still keeps its zero value.
In comparison with other programming languages, MultiCharts PowerLanguage doesn't have uninitialised variables.
Re: Newb question
Thanks for ReplyIt's not possible to make a variable without also initialising it at the same time.
One Follow up,
Code: Select all
value1 = 0
if value1 = 1 then
Begin
Vars:
Special_Index(0);
Special_Index = 100;
End;
Just wanted to make sure that I was understanding right that when you initialize a variable even in a Begin section that never begins, It will be initialized.
Thanks
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Newb question
When you compile a study, MultiCharts would parse the codes and collect all the declarations.
The variables are initialized at compilation, not when you run the indicator.
The variables are initialized at compilation, not when you run the indicator.
Re: Newb question [SOLVED]
Awesome, Thanks TJWhen you compile a study, MultiCharts would parse the codes and collect all the declarations.
The variables are initialized at compilation, not when you run the indicator.