a problem about assignment for parameters

 
A:

bool isFirst = true;
datetime  time_current;
int init(){
   if(isFirst) 
   { isFirst = false; 
    time_current=TimeCurrent();
    }
B:

extern bool isFirst = true;
extern datetime  time_current;
int init(){
   if(isFirst) 
   { isFirst = false; 
    time_current=TimeCurrent();
    }


Regarding codes 'A' and 'B', after they have been attached to a chart, the parameter, time_current, will never change when timeframe is changed (never be initiated again) in 'A', but do in 'B'; however we can set the parameter ,
time_current, when the code is attached to a chart in 'B', but we can't do like this in 'A'; (of course, the assignment when attached in this code is nonsense here, but i will in other place.)
So how to  set variables' value when EA is being attached like B and the variables can never been changed when shift time frame like in A?
 
I do-not understand why are you using this flag. Are you trying to stop something from happening when the program goes through a de-init and re-init cycle? Is this for an indicator... is this for an expert advisor? Please list the cases you're trying to avoid by using that variable.
 

If you want persistant data write it to a file or set a global variable.

 

Haven't you already covered this here?

https://www.mql5.com/en/forum/147862

 
GumRai:

Haven't you already covered this here?

https://www.mql5.com/en/forum/147862


yes, i am

but this problem can't be resolve until now

so i list it here more clearly.

 
vx0532:


yes, i am

but this problem can't be resolve until now

so i list it here more clearly.

Perhaps you should re-read the advices already given?
 
vx0532: So how to set variables' value when EA is being attached like B and the variables can never been changed when shift time frame like in A?
When in doubt, THINK.
bool isFirst = true;           // Can't be changed by human.
extern datetime  initial_time; // Can be changed whenever, but used on first load only.
datetime  time_current;        // Can't be changed = initial_time on first load.
int init(){
   if(isFirst) 
   { isFirst = false; 
     time_current=initial_time
   }
Don't double post.