Your code does not match your description. It is relative to both the current bar and the previous bar, which is wrong. Don’t call priceC(1).