Is it really impossible to initialize external with a non constant ?

 

All in the question as I'm not sure, thanks.

If it is possible then how to initialize a date ?

 

Can you please specify what you mean with an "external" ?

 

If you mean a variable defined at the beginnig of an EA like

extern int MAPeriod = 12;

then it is not possible.

The idea of the "extern" variable it to use it for a manual data input at the beginning of an EA or indicator, so its not provided to use it with different values when starting the program, as it can be changed from the user.

What it the intention of your question, what do you want to do ?

Regards, Klaus

 
knatterton:

If you mean a variable defined at the beginnig of an EA like

extern int MAPeriod = 12;

then it is not possible.

The idea of the "extern" variable it to use it for a manual data input at the beginning of an EA or indicator, so its not provided to use it with different values when starting the program, as it can be changed from the user.

What it the intention of your question, what do you want to do ?

Regards, Klaus


Why is not possible?

extern int Something=1;

init()

{Something=5;}

start()

{

Comment(Something);

return(0);

}

 
EADeveloper:


Why is not possible?

extern int Something=1;

init()

{Something=5;}

start()

{

Comment(Something);

return(0);

}


Of course you can do this and it changes the value of "something", but it does not change the value of "1" when placing the indicator in a chart and entering an input - I thought this was ment to achieve, so that the input can be changed at each start of the EA.
 
forexgenuine:

All in the question as I'm not sure, thanks.

You can't since extern variables are static (as well as all variables declared on a global scope).
 

I wanted to do something similar - allow user to either drag the EA to the desired price level or to enter it manually as number.

You can define the variable with some default value (for example extern StartPrice=0) and in init() check if user entered something else. If not, just initialize it to whatever value you need.

 
via a Text or CSV file
 
EADeveloper:


Why is not possible?

extern int Something=1;

init()

{Something=5;}

start()

{

Comment(Something);

return(0);

}


Yes that's what I want but with date it doesn't seem to work as I tried with TimeCurrent it always return date 1970!
 
sxTed:
via a Text or CSV file

How ?
 
knatterton:

Of course you can do this and it changes the value of "something", but it does not change the value of "1" when placing the indicator in a chart and entering an input - I thought this was ment to achieve, so that the input can be changed at each start of the EA.

Not sure to understand but what I want to do is that I have an indicator which inputs varies with date and I want to initialize it with TimeCurrent so that I don't need to change it by hand each time to current date.
Reason: