Setting gradients
It doesn't matter whether you start at the top or the bottom but, once started, keep going in one direction.
Presumably you have a spline height fixed at the top (let's say t in metres) and at the bottom (b in metres). Count the number of baseboard squares between the bottom and top of your section of track to be graded. Subtract b from t, multiply by 10 and divide by the number of squares. Use the answer as the gradient to type into the set gradient box. Apply that spline by spline from the bottom upwards. Or multiply that number by -1 and apply it downwards.
So, if the top height were 6, the bottom 4 and there were 25 squares between you would need a value of (6-4)*10/25 = 0.8
Don't set the gradient on the last bit - ie between the penultimate spline point and the top or the bottom spline point. Instead measure the gradient that has resulted on that section. If you don't like it, change your applied gradient and redo the whole grade again.
The gradient in that last piece, top or bottom, should ideally be shallower than for the main part and certainly no steeper.