Close At Profit Expert Advisor For MT4
WE IMPROVED THIS EXPERT ADVISOR FOR YOU!!!
PLEASE NOTE: This expert advisor was publicly available for free usage on other websites and is not programmed by us. We explain the functionality and possible improvements of the EA. Furthermore, we are convinced that fully automatic Expert Advisors will fail in the long run. On the other hand, our semi-automatic approach with detecting the best setups and then activating our Expert Advisors (e.g. V-Power EA, EdgeZone EA) produced many successful traders and some of them even got prop traders at prop trading firms. Therefore, we added a similar semi-automatic trading feature (to allow only buy or only sell trades) to the free Expert Advisors. You can download the modified version here and enjoy!
Table Of Contents:
- Close At Profit Expert Advisor For MT4
- The Close At Profit Expert Advisor For MT4 – Entry Criteria
- The Close At Profit Expert Advisor For MT4 – Exit Criteria
- The Close At Profit Expert Advisor For MT4 – Room for Improvement
The Close at Profit Expert Advisor is a MetaTrader4 program that handles trade closure based on the inputs of the user. Depending on the user, the expert advisor can close trades only on the current symbol or all the trades on the trading account. In the image above, the selected option is to close all trades on the trading account. Since the net profit is still negative (-55.12 dollars), the trades cannot be closed yet. This utility works both in five-digit or four-digit forex brokers.
There is an inherent risk involved in using this program. If the user is not careful or not well-informed, he might suffer losses if he has inadvertently activated some options. By default, only the option to close profitable trades is enabled. However, if he accidentally enabled the option to close losing trades, he might be surprised about the consequence. Therefore, the user must fully understand every variable provided in the expert settings.
The Close At Profit Expert Advisor For MT4 – Entry Criteria
The Close at Profit Expert Advisor runs its algorithm on every tick. Every time a new tick comes in, the expert advisor calculates the number of open orders, total profit and number of lots for the current symbol or the whole trading account depending on the value of the AllSymbols parameter. The value set by the user for this parameter is critical as it dictates how the robot will close trades.
Though the expert advisor appears to be simple, looking at the information displayed on the chart, it is actually a powerful tool when set correctly. The options available to the user to adjust are presented and discussed below, along with their default values:
- useProfitToClose = true – When this parameter is set to true, the expert advisor will close trades when the net profit is greater than the amount set in the next bullet point.
- profitToClose = 20 – The value of this parameter is expressed in the currency of the trading account. If the trading account is in US dollars, this value will be in US dollars. If the total profit of the current open trades goes beyond 20 dollars, the trades will be closed provided the parameter above is set to true.
- useLossToClose = false – If this parameter is true, the robot will close all open trades when the drawdown goes beyond a threshold. The default threshold value is 100 dollars (see next bullet point). If the setting is false, the drawdown will not be monitored.
- lossToClose = 100 – If the setting above is true and the account experiences a drawdown of 100 dollars, all open trades will be closed by the robot to keep the trading account healthy.
- AllSymbols = true – If this option is true, the expert advisor will manage all the trades in the trading account. If false, the robot will only close the trades in the current symbol where it is attached.
- PendingOrders = true – If this option is true, the expert advisor will close pending orders as well on the current symbol or on the trading account.
- MaxSlippage = 3 – This parameter is expressed in points, not pips. It defines the maximum slippage that the user allows for trade closure. If the client terminal or server fails to respond quickly to the request for trade closure and price has moved more than 3 points since, the request becomes void.
- showMenu = true – The user can display on the chart or hide the information provided by the expert advisor by setting this value to true or false.
- menuColor = Aqua – This is the color of the text for open trades, total lots and net profit of all open positions on the current symbol or on the trading account.
- variablesColor = Gold – This is the color of the values for number of trades, total lots and net profit of open positions for the current symbol or the trading account.
- font = 10 – The user can increase or decrease the font size of the text and values displayed on the chart by setting a higher or lower value for this parameter.
As a trade management tool, the expert advisor does not use any type of technical indicators. It only works when certain conditions are met based on the parameters set by the user in Inputs. There are at least three conditions that must be carefully set by the user. These are the conditions for closing winning trades, closing losing trades and scope of trade closure.
As previously mentioned, the robot can close either the trades in the active chart or all trades in the trading account. If the user chooses to close the trades in the current chart, he must manually tweak the relevant variable in Inputs. This is done by setting the value of AllSymbols parameter to false. After this is done, the user can see that the profit value updates to reflect the net profit in the current symbol (see image above).
The Close At Profit Expert Advisor For MT4 – Exit Criteria
The Close at Profit Expert Advisor only has two exit criteria related to closing trades. First, the user must define the scope of the trade closure operation (local or global). After this, if the condition for closing profitable trades is true and the net profit of the open trades exceeds a specific amount, the trades in scope are closed in profit. If the condition for closing losing trades is true and the net loss of the open trades goes beyond a certain amount, the trades in scope are closed in loss.
The Close At Profit Expert Advisor For MT4 – Room for Improvement
While the Close at Profit Expert Advisor is a powerful utility, its appearance on the chart does not reflect this capability. The displayed information is too simplistic and is not pleasing to the eyes. The overall presentation could use some improvement. One possible improvement is to use buttons instead of labels. It is also a good idea to add a background to highlight the displayed information.
More information can be added to the chart. This includes the four main parameters and their default values so that the user can easily see which conditions are enabled and which are disabled. These parameters are the useProfitToClose, useLossToClose, AllSymbols and PendingOrders. It would be better if the AllSymbols variable is placed at the top of the display or in the Inputs as it is the most crucial setting.
Code review is also necessary to bring the code up to the date with the latest changes in MQL4 programming. In the code, there are four instances where functions should have returned some values but did not. In those instances, the functions should have been defined as void instead of integer or Boolean. The order select function is also outdated on seven occasions and is redundant three times, meaning the function appears twice one after the other. Further, the variable holding the value for maximum slippage provided in Inputs is not used at all in the functions calling for trade closure. These are all warnings, though, not errors, but can be annoying. This means that the code has not seen updates for a while.
If the user wants to use this utility to close trades in a specific symbol, he must attach the tool to that symbol, which might be time-consuming. As a remedy, it is a good idea to put one variable in Inputs containing the name of the symbol whose trades should be closed. This might require some changes at some points in the code, but it is easy to implement.