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); }
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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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