I am developing an air traffic control radar simulation.
At what minimum distance between two aircraft in mid-air should a conflict alert be given?
The STCA (Short Term Conflict Alert) or pre-alert settings depend on the radar client in use and the ACC's or ARTCC's own standard operation procedures. Some ATC systems give a warning before a loss of separation can occur if criteria are met, informing the controller of a possible conflict. Factors can be clearing aircraft on the same altitude / flight level, aircraft on converging flight profiles, lateral or vertical separation reducing below threshold values, e.g. where 5nm lateral separation is required, a STCA could be set to occur at 7nm lateral separation.
The minimum radar separation between aircraft depends on airspace (TMA area vs enroute area), aircraft equipment and airspace separation requirements (RVSM vs CVSM), flight rules (e.g. IFR to VFR is not separated outside class C airspace in Germany) or local rules imposed by the Civil Aviation Authority.
The general rule of thumb for IFR separation in most countries (as most countries follow RVSM rules):
Oceanic separation is achieved differently, as non-radar procedures are in place. The separation in non-radar environments is achieved procedurally and through position reports and timing.
There are two main systems like the one you describe in use today: Medium Term Conflict Detection (MTCD) and Short Term Conflict Alert (STCA).
Common for both of them is that they do not provide an alarm when there is a certain, fixed distance between two aircraft.
Both systems rely on advanced data processing and 4D-trajectory calculations to estimate the future position of aircraft. If these calculations detect a future conflict, the systems will be triggered.
The systems will provide a warning to the controller, when a loss of separation (LOS) is expected to occur between two aircraft at some point in the future. The STCA will usually be triggered when the system calculates that the minimum separation between two aircraft will be violated within 2 minutes. For MTCD, this time frame is much larger, up to 20 minutes. The important thing to note is that the warning does not go off x minutes before the aircraft are going to hit eachother; rather, it goes off x minutes before the legal minimum separation will no longer exist. The warnings are designed like this, so that the controller will have time to solve the conflict before the minimum separation is violated.
As for the specific times used before a warning is triggered, it varies from system to system - and it varies within the same system too. In a busy TMA environment where planes are generally close and also flying at slow speed, meaning they are quite maneuverable, an STCA will go off much later compared to an ACC environment, where planes are generally further apart, and moving at higher speeds.
Modern ATM systems are simply so complex that there is no simple answer to your question.