Your script looks correct to me.

I would use priceHigh for FractalHigh and priceLow for FractalLow, though. Shifting the Fractal by 2 bars probably also makes not much sense for signal generation.