2007 S550 Mercedes Benz S class Transmission problem

I believe my car Is having transmission problems. Sometimes my car will start and run but it won't accelerate when I put the car in drive or reverse. Then later in the day it will start, run and accelerate when being driven. Also while the car is driving I've noticed that the gears are slipping which causes the car to jerk or shift hard. Any answers anyone?