Script – OpenOrder 1.0

Open 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 order will open. Although the process is already easy we can still improve it and work around some limitations. The OpenOrder 1.0 script can help you open orders with more options and more automation. Two of the biggest limitations when you open an order with the defaul MetaTrader process are:
  • Manual calculation of the position size
  • Inability to set the magic number
As you may know and you can also read in the article Calculate Position Size there are risk management rules to protect your account. One of these rules involves to set a stop loss and calculate the position size depending on the pips 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 1.0. The script in fact 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 have an option so that you can set the magic number for the order and an optional comment. You can download the script for educational purposes and test it on a Demo Account. Download Here download-openorder_v1-0-1 The parameters accepted by the script are:
  • Specity position size, if you want to set a fixed size for your order, this however is ignored if the next is true
  • Select true if you want to use the risk % to calculate the position size, can be true or false
  • % of available balance to risk, used in the calculation of the position size
  • Type of order, can be BUY or SELL, mind the capital letters
  • 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
download-openorder_v1-0-2 The script can be very useful in some occasions and surely 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. Download Here Please leave a comment if you have any feedback or doubt and remember to like us on Social Media! I would really appreciate also suggestions for improvements and reports of any bug found. Thank you!

If you want to save hours of research and coding and you want to see some professional code check this out! You can use it to build your own EA!

2 thoughts on “Script – OpenOrder 1.0”

  1. Hi,

    how the lotsize will be calculated?


    script is working with brokers with 4/5 digits?

    Thanks in advance, Tom.

    • Hi Tom,
      Lot size is calculated with the Account Balance, not Free Margin.
      The script works with both 4 and 5 digit brokers.



Leave a Comment

We use cookies to ensure that we give you the best experience on our website.