You can find a comprehensive review on the recommended pratice for magnitude computation in the "New Manual of Seismological Observatory Pratice, 2nd Edition", edited by the IASPEI (International Association for Seismology and Physics of the Earth Interior), available at link attached below.
If you are working with a local seismic network, a simple equation may be good enough:
M(local) = log A + 1.7 log r - 0.15
A = horizontal displacement amplitude ( peak to peak) in um, if you are observing vertical components, multiply them by 1.7. Normally your seismometer will give you velocities of the ground motion,dividing them by 2 pi f yields displacements ( f being the dominating frequency)
r = epicentral distance in km
the last coefficient can be adjusted by looking for events, which are listed in seismological catalogues (USGS etc.)
Please download this paper from my profile. It will help you with some of the issues.
The paper: Calibration of an M L scale for South Africa using tectonic earthquake data recorded by the South African National Seismograph Network: 2006 to 2009
Ian Saunders, Lars Ottemöller, Martin B. C. Brandt, Christoffel J. S. Fourie