so does this resistor have to be close to the relay or it does not matter ?
.
What would be the best resistor value for that ? 120Ohm like suggested by
Bluejets ?
It doesn't matter because the resistor is not connected to the relay. And this is most likely a non-issue for your relay driver. Although parasitic oscillations are the bane of experimental setups, they are generally solved by improving the layout and circuit interconnections.
What
@WHONOES is talking about is "rolling off" the MOSFET frequency response at its gate-to-source interface, which in your instance is the Arduino low-impedance output driving the MOSFET gate (or BJT base) through a low-valued resistor. In the case of a MOSFET, there is appreciable gate-to-source capacitance (a few picofarads) and almost infinite gate-to-source resistance because of its insulated, floating, gate construction. It doesn't require much resistance in series with the gate-to-source capacitance to attenuate any undesirable positive feedback signal below a level sufficient to support parasitic oscillation. And, because the MOSFET gate-to-source resistance is so large, any resistor you choose between a few hundred ohms and a few megohms is going to have minimal effect on "how hard" the MOSFET turns on, although it will affect "how fast" the MOSFET turns on (and off) because the charge on the gate-to-source capacitance is moved through this resistance and it is this charge that determines whether the MOSFET is conducting or not conducting. Try a value between one hundred ohms and one thousand ohms to start with.
The situation is slightly different with BJTs because the forward-biased base-emitter junction represents a lower impedance and does not present much capacitance, but the "solution," if it is necessary, is the same: introduce a series-connected RC network between the Arduino output and the transistor base that will "roll off" the frequency response sufficiently to prevent parasitic oscillations.
However, before trying to solve a problem that probably does not exist, use an oscilloscope to verify that parasitic oscillations are actually occurring during the state-transition edges of the Arduino output. Such oscillations will bias the transistors involved into linear regions of operation and may cause excessive power dissipation during the time intervals when the oscillations occur.