Variables

 

Hello,

if one changes the period of the chart or enters new values to the indicator, than all variables are put back, but if one simply only switches off the terminals and then switch it on again the variables are not put back again?

Who knows the problem and a solution?

Eaxmple:

bool first=true;

int start() {

if(first==true){

Print("first is true ",TimeToStr(Time[0],TIME_DATE|TIME_MINUTES));

first=false;

}

}

Now first you get the issue from the Print() function, now you switch down the terminal and after example 2 minutes you switch the terminal on again, and now you dont get a issue from the Print() function again, but if you just change the period or kompiler the script you get a issue again, because the variables are all put back to their onset, but if you switch of the terminal and than switch on again it dont works, because why please?

 

sounds like just turning the terminal off and on doesnt init the indicator(just runs start loop only?).

it dont look like you have the bool declared under init tho?

 

Hello lowphat and thank you for your help! I have declared the bool variable outside any function, so no in the start function like its seen in the example above and also not in the init function.

That is a strange problem and I dont understands it.

What I want ist that the variable be reset after the terminal is shot down once and switch on again, but it doesnt.

 

Hello again, I think maybe my explanations are not so understandable, because of that I just want to ask it more simply.

Is there a possibility as one all variables become reset after the terminal is switch off and on again. Like when the chart symbol or timeframe has been changed?

 

I have make a new Test with this following Code:

bool first=true;

int init() {

first=true;

return(0);

}

int start() {

if(first==true){

Print("Time ",TimeToStr(Time[0],TIME_DATE|TIME_MINUTES|TIME_SECONDS));

first=false;

}

At 15:59 PM there was make a Print() message with the Time.

Then I have close terminal.exe and after 30 minutes I have open terminal.exe again, the result was no new Print() massage was make, new tick come in but no Print() message where made.

But why not, dont must it be? If the terminal.exe is open then the init() function must set the boolen variable first to true and so a Print() message must normal be print, but it doesnt, and I dont now why, you?

 

Something new about my Test.

It's about an indicator.

I have test it again with still more Print() messages one in the init() and one more in the start() function.

It run as follows:

Code:

bool first=true;

int init() {

first=true;

Print("two ",TimeToStr(Time[0],TIME_DATE|TIME_MINUTES|TIME_SECONDS));

return(0);

}

int start() {

Print("three ",TimeToStr(Time[0],TIME_DATE|TIME_MINUTES|TIME_SECONDS));

if(first==true){

Print("Time ",TimeToStr(Time[0],TIME_DATE|TIME_MINUTES|TIME_SECONDS));

first=false;

}

1. The Indicator with script is put on the chart.

2. I get 3 Print() Messages with same time value in the experts journal.

3. I close terminal.exe and wait some minutes.

4. I start terminal.exe again, the chart with the indicator is open and i get only from the print() function which is directly under the start() function a message, from the other print() functions nothing is return.

That seems to me like nothing ist be launched new. All variables are at they old values.

Now what is make me more and more nervously or little crazy, is that if I close and open terminal.exe now again, so at the second attempt, it seems like then the variables be reset and all is launched new now. But this only at the second attempt, I dont do there a mistake because already one day without traces I'am testing this, perhaps I misunderstand a little issue but I dont now what.

 

Hello again,

I think now I have find i solution for me.

In the init() function I declare first a global Variable

dd=GlobalVariableSet("dl",1.1);[/PHP]

Then in the start() function I check first a expression about the gloabal Varaible and then delete the varaile komplett.

[PHP]

if(GlobalVariableCheck("dl")==true ){

df=1234;

}

GlobalVariablesDeleteAll();

The advantage is that the gloabl variable every time when closeing the terminal.exe programm and switch on again is be changeing, but with other varaibles there was the problem that they are not chaning/launched by closing und switching on again the terminal.exe.

Now in my test this solution works like I want and I think it remains in such a way.

Reason: