Hi Mansour,
The Notation Reference manual can be difficult to follow at first. We all suffer that.
Now that it's cleared up, just by way of example I use this:
dynamicsX-offset =
#(define-music-function (offset)
(number?)
#{
\once \override DynamicText.X-offset = $offset
\once \override DynamicLineSpanner.Y-offset = #0
#})
If you are using 2.18 you need to use the parser and location arguments - no longer needed in recent versions.
I can't remember why you need to set the line spanner offset as well. But at the time I wrote this it seemed necessary. Could be redundant.
Andrew