• Overview
  • Reviews
  • Comments

Auto Close Orders

The purpose of the EA was to help the trader in working with manually opened orders and to automatically control certain events for closing orders. Additional objective - terminal operation in absence of the trader. Minimum objective - as inconspicuous to the DC as possible. The idea behind the program is quite simple and is defined by the parameters used.

It is designed for the automatic closure of orders when an event, defined by the parameters, occurs.

The first two events are standard - TakeProfit and StopLoss. They need no further explanation.

The additional events - percentages of the maximum profit MaxCurretProfit and loss ProcRisk. MaxCurretProfit closes orders when a specified profit percentage is reached, ProcRisk closes the orders when the specified loss percentage is reached, and the profit and loss are considered independently for both Buy and Sell.

To automatically close all orders participating in competitions arranged by the dealer centers in order to attract the traders to them, there is the EndConcurs parameter: once the end date and time of the competition is reached, all the orders are closed.

There is also a widely used TrailingStop0. It has been reworked: the value of a particular TrailingStop value is in a direct relation to the TrailingStopk parameter and the difference between the current price and the order opening price. The operation principle on the screenshot 1.

A new parameter I had never seen before - ATakeProfit and the associated parameter nTrendPeriod. The order is closed when both the trend direction changes and the order opening price is exceeded by ATakeProfit. The operation principle on the screenshot 2.

Events for BUY orders are defined by parameters:

  • TakeProfit = 0 - when exceeding the weighted average price of the instrument by a specified number of points;
  • ATakeProfit = 0 - when the instrument price is exceeded by the specified number of points, with the condition that the K line of the iStochastic(26,8,10) indicator crosses the D line from above (see screenshot);
  • nTrendPeriod = 2 - number of the iStochastic indicator timeframe: 1 - 1 min, 2 - 5 min, 3 - 15 min, 4 - 30 min, 4 - 1 hour, 5 - 4 hours, 6 - 1 day, 7 - 1 week and so on ;
  • TrailingStop0 = 0 - the number of points for the Trailing Stop. A real STOPLOSS is placed;
  • TrailingStopk = 0 - the deviation coefficient of the Trailing Stop from the constant deviation line in the range from -1 to +1. If +, the current value of the TrailingStop increases with the price. If 0 (zero) - the usual Trailing Stop (see screenshot);
  • StopLoss = 0 - when the instrument price moves into a loss by a specified number of points from the highest order opening price;
  • ProcRisk = 0 - when reaching the specified loss percentage;
  • MaxCurrentProfit = 0 - when reaching the specified profit percentage;
  • EndConcurs = D'2030.12.31 23:59:00' - Close all orders on the chart the EA is attached to when the specified date and time is reached. Can be used during the participation in a competition.
  • LotDecimal = 2 - representation precision of opened lots;

Similar for SELL orders.

A zero value disables the corresponding parameter.

All the parameters work inconspicuous to the DC, except TrailingStop.

TrailingStop and ATakeProfit work independently for each order, the other parameters close all orders of the corresponding direction.

Important! No expert, nor any other automated trading program can guarantee a 100% winning strategy. The strategy of decreasing such loss is called money management. This task is most neatly performed by the parameters which control the loss size - StopLoss and ProcRisk: they close the orders at a certain limit value of the loss. But the wining parameters - TakeProfit and MaxCurrentProfit - are just as important, they do not allow to lose everything in pursuit of profit. TrailingStop - is a compromise: to get at least something. The absolutely winning strategy is possible only for the infinite value of your deposit.


  1. The computer must always be connected to the Internet during the program operation;
  2. Work on Demo accounts to familiarize yourself with the product;
  3. There is no point in checking it in the strategy tester as the EA does not open orders.
No reviews