If you just want a "ballpark" guess as to the number of loops required, there are many sources that give expected stress levels for expansion loops of particular dimensional ratios. Probably, though, you want to do some analysis to be a little more precise.

Typically, you want to anchor long pipelines between each loop, or each pair of loops. You choose an arbitrary distance between anchors (the longer the better) and find how big an expansion loop you need (the longer the anchor-to-anchor distance, the bigger the loop, but you want smaller loops). So you have to balance two conflicting goals - long spacing between anchors vs. small loops desired.

If you have minimal lateral loads due to wind, waves, seismic, etc. you might be able to accomplish both, but normally after one or two loops you have utterly destroyed the ability of the system to resist horizontal loadings. Don't forget to consider external occasional loads parallel to the long run of the pipe - if you have too many loops between anchors these loads could cause one or more pipe shoes to fall off their support steel.

After a few iterations on the anchor spacing and number of loops, you have a design where you have balanced the cost to construct, support, restrain, operate, and maintain the piping system. Usually you will need input from other disciplines (civil, structural, process, I&C, construction, operations, and maintenance) and from the owner in order to make this decision effectively. Note that process typically wants a few big loops (fewer fittings to produce head loss), while the other disciplines would rather have a lot of small loops.
_________________________
CraigB