Answering my own question, as it seems to be a general problem, I still don't understand.
However I had to move the calculation of the ATR outside of the if
clause. Can someone comment, why this is needed.

Code:
static int debug = 1;
 
var dailyATR() {
  TimeFrame = 4;  
  var atr10=ATR (10);
  return atr10;	
}

function run()
{

//set(LOGFILE);
set(STEPWISE);
StartDate = 20160101;
EndDate = 20160825;
StartWeek = 10000;
Stop = PIP*25;
Trail = PIP*25;
BarPeriod = 60;
LookBack = 60*4 ;

asset("EUR/USD");

var  dailyATR = dailyATR(); 
TimeFrame =  1;
var hourlyATR=ATR (10); 
if (hour() == 0){
	if(debug && Bar > LookBack) 
	     debug = msg("\nrun()\nATR10_daily %f\nATR10_hourly %f\nTimeFrame %d\nStartDate: %d\nStop:%.4f \nTrail: %.4f,\nBarPeriod %.0f\nLoopback %d", 
		 dailyATR ,hourlyATR, TimeFrame, StartDate , Stop, Trail, BarPeriod, LookBack);
	}

}