Borisov-Joyce constructed a real virtual cycle on compact moduli spaces of stable sheaves on Calabi-Yau 4-folds, using derived differential geometry. We construct an algebraic virtual cycle. A key step is a localisation of Edidin-Grahams square root Euler class for $SO(r,mathbb C)$ bundles to the zero locus of an isotropic section, or to the support of an isotropic cone. We prove a torus localisation formula, making the invariants computable and extending them to the noncompact case when the fixed locus is compact. We give a $K$-theoretic refinement by defining $K$-theoretic square root Euler classes and their localis