Thanks for the bug report! I can confirm the problem - ATR indeed returns a wrong value when TimeFrame is > 1. It's a bug. I'll forward this to the developers. This will be fixed.
- Your method to emulate the MT4 atr is correct, but a little heavy. You need only 2 lines for replacing all time frames with function arguments:
var atr(int tf_minutes, int length)
{
TimeFrame = tf_minutes/BarPeriod;
var r = ATR(length);
TimeFrame = 1;
return r;
}
- Your method to set the Lookback period does not look right. Maybe there's some misconception. LookBack is the number of bars before the test period. For 150 days, it's 150*1440/BarPeriod.