The best way to do this is to create a SUBVAR that parses the JOBID. This way you can use the same SUBVAR for any job.
For Oracle this is the SQL to get the restart count from the JOBID:
select nvl(substr('{jobid}',length(cast ({jobid} as int))+2),0) from dual
The condition would then be:
After always true: if #restart_count LT 5 RESTART ON ABORT