The problem is not about shifting, but about series giving the wrong value:
vars Prices = readLatestPrices("GC_J"); //This gives the correct price series
vars PricesDiff = series(Prices[0] - Prices[1]); //will just be 10,10,10,...
However, if I manually loop through the Prices series to create PriceDiff, I get the correct values:
vars Prices = readLatestPrices("GC_J"); //This gives the correct price series
vars PricesDiff = series(0);
int i;
for(i = 0; i < LookBack; i++) PricesDiff[i] = Prices[i] - Prices[i+1]; //will be 10, 3, -5, 4,...
I think it's appropriate to do so right?