What equation has a slope of +1, followed by a slope of -1, is continuous, etc? In its most general form, this will suffice.
a is a vertical offset, b the location of the break (transition) point in the slope. Be slightly careful in your choice of b, as if it was outside the range of the data, the optimization will have problems.
Also, be careful in that you cannot add another coefficient in front of the absolute value, as that would blow away the required slopes.
And finally, of course the functional form I have written is not differentiable. But it is continuous, and has the exact properties requested.