´*´ - constant expected

 

does any one know why i am getting this error and how to fix it, this is the line,


extern int    ProfitTarget         = (AccountEquity()*1.01);

 

extern int needs to be a constant.

so copy the initial constant parameter to a new variable and then assign the product of the calculation to the copy.

 
David Buckley:

does any one know why i am getting this error and how to fix it, this is the line,


extern int    ProfitTarget         = (AccountEquity()*1.01);

maybe like this :)
double init_target=(AccountEquity()*1.01);
input double ProfitTarget=init_target;
 
Yohana Parmi:
maybe like this :)

oops.. still get error :(

'init_target' - constant expected


 

it should be like this :

input double init_target=1.01;
double ProfitTarget=AccountEquity()*init_target;
( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)
 
double ProfitTarget=AccountEquity()*init_target;

Only assign constants to global/static variables. The fact that the above code actually compiles doesn't make it correct.

AccountEquity, changes over time but your variable never does. Assign it in OnTick

Reason: