Help for function call problem

 

I defined a function like this:


int CalculateBars(int LastBar, int PastBars)
{
datetime _time = StrToTime(FixedDateTime), _time0 = StrToTime(FixedDateTime0);
int LastBar = iBarShift(NULL, Period(), _time, false), PastBars= iBarShift(NULL, Period(), _time0, false);

return(LastBar, PastBars);
}


When compiling, it showes an error for return, How to return the values?


Thanks


MontS

 

Try this

int CalculateBars(string FixedDateTime, string FixedDateTime0)
{
datetime _time = StrToTime(FixedDateTime), _time0 = StrToTime(FixedDateTime0);
int LastBar = iBarShift(NULL, Period(), _time, false); int PastBars= iBarShift(NULL, Period(), _time0, false);

return(LastBar, PastBars);
}

 
Roger:

Try this

Thanks, BUT, no, it showed: '(' - function definition unexpected.

 

I forgot, you can't return two values, sorry. Change logic.

 

return only can return one value !!!!

you can use int CalculateBars(int& LastBar, int& PastBars)......

to return more values like LastBar and PastBars,

no need return....,

use return only can return one value !!!!

 
DxdCn:

return only can return one value !!!!

you can use int CalculateBars(int& LastBar, int& PastBars)......

to return more values like LastBar and PastBars,

no need return....,

use return only can return one value !!!!

Great, many thanks, I tried int CalculateBars(int& LastBar, int& PastBars), and it works.


Thanks, have a good weekend.


MontS

Reason: