About 20 Minutes
Having taken the Airtrain several times in the past month-2 months, I would say that 20 minutes is about the right amount of time that I would allot for getting from Terminal 7 to 4 (or vice versa).
If I remember correctly, 4 is a stop to itself, then 5 and 6 are combined, then 7 is a stop all to itself, so its actually just two stops rather than three between the two.
Since I haven't gotten on or off at either, I don't know what facilities there are at either terminal for getting to/from the actual terminal to the AirTrain station but I would allow for at least five minutes at either end for that. Give five minutes for the actual ride on the train, and another five for waiting and that should be about right. That leaves you an hour and forty minutes to get through INS, customs, baggage, etc. You should be OK.