Popular results
Position Sizer
Calculate risk-based position size directly in your MetaTrader platform and execute a trade in one click or a press of a button.What Is Forex
Learn what Forex is and how it works from this simple explanation.Supertrend
Download the Supertrend indicator for MT4 and MT5 to detect trend changes based on the price action.Position Size Calculator
Calculate your position size based on risk, stop-loss, account size, and the currencies involved. A simple online calculator for quick results.Open Order Script for MT4
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:
- Manual calculation of the position size.
- Inability to set the magic number.
As you may know, there are risk management rules to protect your account. One of these rules involves setting a stop-loss and calculating the position size depending on the money you are risking.
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:
- Specify position size if you want to set a fixed size for your order. This parameter is ignored if the next one true.
- True if you want to use the risk % to calculate the size.
- % of available balance to risk — used in the calculation of the position size.
- Type of order — can be BUY or SELL.
- Take Profit in pips — if you want to set a take-profit price.
- Stop Loss in pips — if you want to set a stop-loss price.
- Magic number if you want to specify one.
- Comment for the order if you want one.
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.
Downloads
➥ OpenOrder ScriptTo install the script, please follow the instructions below:
- Download the script archive file.
- Open the MetaTrader 4 data folder (via File→Open Data Folder).
- Open the MQL4 Folder.
- Copy all the folders from the archive directly to the MQL4 folder.
- Restart MetaTrader 4 or refresh the list of scripts by right-clicking the Navigator subwindow of the platform and choosing Refresh.
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.