If the enemy heroes are always near each other then I suppose you could do something like this.
Choose one of these enemy heroes as the "leader" and periodically compare 2 things to your unit:
1: The angle between the leader and the unit to determine that the unit is facing away.
2: The unit's distance from the leader to determine that the unit is moving away and not closer.
#2 could be handled like this:
set variable Distance = distance between position of leader and position of unit
if (Distance < previousDistance) then set variable IsMovingAway = True
set variable previousDistance = Distance
Then you could add onto the If Then Else statement like:
if (#1 is true and Distance < previousDistance) then set variable IsMovingAway = True
I forget the math for the "facing away" stuff but there's probably an example of this idea in here:
[Solved] - Angles (how to detect a backstab attack)?