hey,
can someone check the following code for calculating the ADR? it is coded that way that it skips sunday bars...
thank you, cheers!
can someone check the following code for calculating the ADR? it is coded that way that it skips sunday bars...
QuoteDislikedint getADR(string s, int days)
{
int adr=0,i=0;
int tmp_days = days;
for(i=1;i<=tmp_days;i++) {
if (TimeDayOfWeek(iTime(s,PERIOD_D1,i)) < 1 || TimeDayOfWeek(iTime(s,PERIOD_D1,i)) > 5) {
tmp_days++;
} else {
adr = adr + (iHigh(s,PERIOD_D1,i)-iLow(s,PERIOD_D1,i)) / MarketInfo(s,MODE_POINT);
}
}
adr = adr/days;
return (adr);
}