hey buddy!
I think you can use something like this (I didn't check it!) that I found at this forum(www.forex-tsd.com/metatrader-4/11409-mt4-api-3.html)
also I found some helpful techniques here(globaleconomicstrategies.com/index.php/global/global-technology/virtual-private-server-vps-with-web-interface-for-metatrader-forex/) and here(becomewebhost.com/virtual-private-server-vps-with-web-interface-for-metatrader-1040.html) for web based metatrader programming (using VPS's!) I think they may help you and solve your problem directly...
in other hand this(www.alpari-forex.com/en/help/metatrader/) seems a good and useful API but I have no experience and study on it!
hope you success.
P.S :
sorry I'm new to stackoverflow and it don't rely enough on me to allow me post more than just one hyperlink, excuse me for them...