Calculate leverage

 
Assuming that I know the required margin for a lot, the size of the contract and the current price, what would be the formula for deriving the leverage of the instrument?
 
looking to make a Script or Expert Advisor for MetaTrader 4 that facilitates the entries in manual operations, making a calculation of the position size automatically, based on a risk percentage of our account and the size of the SL we are looking for. I attached the Request in a Word document and the design and a similar program in the .ZIP.
Files: