How do I obtain the max endurance altitude?
The answer depends on many factors. Things to consider are:


Improved efficiency of combustion engines at higher altitude because of lower air temperature.
Lower power output with altitude due to lower air density, so the most efficient power setting coincides with the best endurance speed, which is close to stall speed.


But not all is better higher up:


Again due to lower temperature at higher altitude, the Reynolds number drops over altitude, even when the higher flight speed to compensate for the drop in air density is factored in. This increases the zero-lift drag and lowers the maximum lift coefficient. For propeller-driven high aspect ratio designs this alone lowers the maximum endurance altitude.


There is more, but those are the main factors. So it depends on engine characteristics, wing loading, planform and airfoil and even on atmospheric conditions. This makes it hard to give a generalised answer – in the end the optimum has to be found for each design individually.

With all caveats, a good candidate for the optimum endurance altitude is close to the service ceiling of the aircraft when optimum loiter speed can be flown at the cruise power setting of the engine. If winds allow: A maximum of wind speed occurs near the tropopause, and in order to keep station even in high winds, it might be impossible to fly at best loiter speed. There are stories of Me-109s which should be flown to the western front from the plant in Augsburg and ended up on airfields in Czechoslovakia, because the pilot got caught in the then-unknown jet stream.



Wind speed over altitude at 40N latitude (picture source).