Download MetaTrader 5

´*´ - constant expected

To add comments, please log in or register
David Buckley
130
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);

Marco vd Heijden
Moderator
5535
Marco vd Heijden  

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.

Yohana Parmi
3092
Yohana Parmi  
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
3092
Yohana Parmi  
Yohana Parmi:
maybe like this :)

oops.. still get error :(

'init_target' - constant expected


Yohana Parmi
3092
Yohana Parmi  

it should be like this :

input double init_target=1.01;
double ProfitTarget=AccountEquity()*init_target;
( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)
whroeder1
15925
whroeder1  
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

To add comments, please log in or register