Thanks for the additional information. Just so you understand, there are two parts to designing a flange. The first part is designing the actual metal part of the flange to ensure that it won't break or deform excessively: that's ASME Section VIII, Division 1, Appendix 2. The second part is designing for sealing performance: that involves the gasket selection, assembly (including bolting), and maintenance.
So, you have a pipe that is 18m long, straight, with fixed ends, that may experience temperature variations of upwards of 20°C. Sorry - that's just bad design. Over the 18m length of the pipe, you may see as much as 4mm of thermal expansion/contraction. And you want to design a flange that will accommodate that?!?
Yes, you need to consider external loads. Yes thermal expansion should be considered. I have to think a little bit more about the Poisson effect, but that doesn't matter - you have bigger issues here. Although Appendix 2 does not explicitly describe how to include for external axial loads, it would be reasonable to add them hydrostatic loads. But just because you can, doesn't mean that you should. This is a bad idea, and although you have stated before that hiring a consultant is out of the question, it appears that you and your design are out of your league, and some expert assistance is required.