Is there a specific formula or way to calculate flex temperature for an Airbus A320?
The RTOW (regulatory takeoff weight) charts are runway and configuration specific, so the length and slope (and permanent obstacles) and all taken care of (see red box below).

There is no manual formula, either the charts or a performance calculator such as the Airbus FOVE or the company's proprietary software.

This is what an RTOW chart looks like:



The information needed (example):


  
  Takeoff from Paris-Orly, Runway 08
  Slat/Flap configuration: 1+F
  Actual TOW = 66 tons
  OAT = 24ºC
  Wind = +20 Kt headwind
  QNH = 1013 hPa
  Air conditioning: Off
  Runway state: Dry
  


Source: Getting to grips with aircraft performance (Airbus via skybrary.aero)

Here's why there is no equation, from the Boeing book Jet Transport Performance Methods:


  Here’s the complication: for the very first increment of time after engine failure, one second, we
  need to calculate the average acceleration in order to find the airplane speed after one second.
  
  But
  we can’t find the average acceleration because we don’t know the thrust after one second. And we
  don’t know the thrust after one second because we don’t know the speed after one second. And
  we don’t know the speed after one second because we don’t know the average acceleration.


What they end up doing is iterative calculations and flight tests to come up with the graphs / tables.