In this study, a fluorescence X-ray spectroscopy system was designed by the Solidworks computer code to detect and measure trace metals. Then, the designed device was simulated and developed by the Monte Carlo method in MCNPX software. The most excellent performance of the trace element detection system was respectively found at 3 cm and 30 cm for source-to-sample distance (SSD) and source-to-detector distance (SDD), respectively. According to the results of different runs of the simulation code, the largest intensity of absorbed X-ray by the detector was obtained for the collimator’ s diameter of 3 mm. In addition, the absence of lead shielding around the surrounding metal walls of the detector, even with the use of a lead collimator at the entrance of the detector window, increases the entrance of background beams to the detector and so, it will cause the reduction of spectroscopic accuracy in detecting trace elements. The least amounts of concentration for detecting arsenic, lead, mercury, zinc, copper, and iron were calculated as 0. 17 mg/kg, 0. 40, 18. 40, 20. 00, 146. 00, and 266. 67 mg/kg, respectively. Due to the concentration and level of pollution of these elements, the rare metal detection device designed for research and educational samples, especially in environmental and agricultural samples, will be extremely practical and useful.