# auto.arima: h irrelevant when xreg used

For all my forecast models (arima with Fourier, tbats, ets and stlf from the "forecast" package in R) I use the following:

model <- auto.arima(x, xreg=fourierf(x, K=y, h=52))


or

model <- tbats(x)


or

model <- ets(x)


or

model <- stlf(x)


then

forecast(model, h=52)


h=52 as that takes my data to the end of this quarter.

I also used multiple regression separately.

I then decided to use ARIMA with the dummy variables I'd used in my regression model:

model <- auto.arima(x, xreg=dummy)


then

forecast(model, xreg=dummy, h=52)


However it doesnt matter if I use h=52 or h=1 or leave it blank, the forecast automatically seems to forecast the total length of my data set i.e. if I had 404 values it forecasted 404 values forward.

Just wondering why this happens and can I restrict the forecast to less?

You use dummy twice - once in fitting, once in forecasting. Thus, dummy presumably has 404 entries, as many as your historical series. forecast() correspondingly gives you one forecast per entry in dummy. (The forecasts will thus also depend on your historical covariate information, which you presumably don't want.)
Solution: feed only as many future covariate values into forecast() as you want forecasts for. (And make sure those covariate values actually are future values.)