Generically, the alert is generated if the traffic is on course to be within a 1/4 mile sphere of your aircraft in the next 20 seconds. This is based on a 3D calculation of your aircraft path and the other aircraft path. It expands a bit as you climb as well since aircraft aren't as close to one another enroute as in the terminal environment.
This does mean that you'll get an alert at larger distances if you have higher closing speeds, and you won't get an alert if you are pointed at one another but you are climbing and the other target is descending.