Everything worked like it should. The only surprise is that MQL truncates integers instead of rounding them, but that's a reasonable definition.
So I don't think the DoubleToInt() function should be necessary at all, unless you want to round instead of truncating. And then you could just use MathRound() instead of DoubleToInt().
Code: Select all
#property indicator_chart_window
string com;
string NL = "\n";
int init()
{
com = "";
int ival1, ival2;
double dval = 34.567;
ival1 = dval;
ival2 = 98.765;
com = StringConcatenate(com, "double-to-int assignment values: ",ival1,", ",ival2,NL);
ival1 = IntParam(dval, 98.765);
com = StringConcatenate(com, "IntParam return = ",ival1,NL);
ival1 = ReturnConst();
com = StringConcatenate(com, "ReturnConst value = ",ival1,NL);
com = StringConcatenate(com, "IntParam return w/o int assignment = ",IntParam(dval, 98.765),NL);
com = StringConcatenate(com, "ReturnConst return w/o int assignment = ",ReturnConst(),NL);
Comment(com);
}
int IntParam(int iparam1, int iparam2) {
com = StringConcatenate(com, "iparam values = ",iparam1,", ",iparam2,NL);
double e = 2.71828;
return(e);
}
int ReturnConst() {
return(24.68);
}
int start()
{
}