Opening an order is quite a simple process with MetaTrader 4: you click New Order, select the instrument, position size, stop-loss, and take-profit and bang! The order will open. Although the process is already simple, we can still improve it and work around some limitations. The OpenOrder script can help you open orders with more options and more automation.
Two of the biggest limitations when you open an order with the default MetaTrader process are:
The other disadvantage is not being able to set a magic number for the order, resulting in limiting the possibility to manage the order with an expert advisor.
The above limitations can be worked around with the OpenOrder script. The script allows you to set a percentage of balance that you are ready to risk and to calculate the position size depending on the stop-loss that you set. The script also has an option for you to set a magic number for the order and an optional comment.
You can download the script for educational purposes and test it on a demo account.
The parameters accepted by the script are:
The script can be very useful in some occasions. Also, it can show you an example of how to open an order if you are learning MQL4.
The script is free to download and use.
To install the script, please follow the instructions below:
You can also read a more detailed instruction on how to perform the installation.
Make sure you enable Allow live trading in the Common tab when executing this script and also in the platform's menu Tools→Options→Expert Advisors. Otherwise, it won't be able to open an order.
If you are interested in building your own expert advisor or knowing more about how to do it, check our MT4 Expert Advisor Template.