Closing Positions in MetaTrader 4 Using Total Profit/Loss, with Trailing Stop.

Closing Positions in MetaTrader 4 Using Total Profit/Loss, with Trailing Stop.

2 March 2017, 13:06
Vladislav Andruschenko
0
161

CloseIfProfitorLoss with Trailing


Closing Positions in MetaTrader 4 Using Total Profit/Loss, with Trailing Stop.

You can enable the Virtual stops (Separate Order), Calculate and Closing separately BUY SELL positions (Separate BUY SELL), Closing and calculate of all symbols, or the current symbol only (All Symbols), Enable trailing for profit (Trailing Profit)

Closing takes place on the deposit currency, points, and % of Balance.

You can set a total loss (in dollars, points, percentage) and an adviser close loss.

You can set the total profit (in dollars, points, percentage) and an adviser close profit.

Positions are closed by profit, points, % and drawdown. The Expert Advisor is designed for use on any account together with any other EA or in combination with manual trading. As soon as the total balance on trades for a given currency pair or all pairs becomes greater than or equal to the value specified in the settings, all positions will be closed and orders will be deleted.

This version is not only capable of closing a position at the specified profit level, but can also trail profit for better results.

You can also tryProfit or Loss PadExpert Advisor for MetaTrader 5.

This panel Advisor is part of our system, "Trade in one click" - VirtualTradePad

The detailed description and examples of use in our blog


Parameters:

  • MagiccOrder - closing by magic number: -1 - all orders;
  • MagikToClose - magic number of positions for calculation and closing;
  • CLP_TralOptionsStep - Step modification trailing for profit.
  • BalanceStart- balance based on which the percent will be calculated. 0 - the variable is filled at the start.
  • Orderdelete - delete pending orders when closing the position.
  • Use_Lots_in_CLP_Points - the EA will also consider the lot of those positions during calculation of profit points. This option can be useful in trading on a hedging account with different lots. 
  • AutoCorrect_LevelCLP - Auto-entered values in the field of our advisor.
  • PROFITLOSS_EXTRASETS4 - Block Alert profit and loss of the deposit currency.


Main Features of the Expert Advisor

This Expert Advisor can close all trades on your account (sorting is available by magic number, symbol and deal type).

Positions can be closed by profit/loss in dollars, points and percent of balance. For example, assume that you want all your trades to be closed if the drawdown reaches 30% of the balance. Install my Expert Advisor and make settings according to the instructions. As soon as the account drawdown reaches the specified percentage, the Expert Advisor will compulsorily close all trades.

Compulsory closing is a recent feature. The Exp - CloseifProfitorLoss Expert Advisor will compulsorily close all trades by all means.

  • OpenHour- time when trading starts (hour).
  • OpenMinute- time when trading starts (minutes).
  • CloseHour- time when trading closes (hour).
  • CloseMinute- time when trading closes (minutes).

Separate Order  = all orders can be calculate and close separately

Separate BUY SELL = BUY direction (all buy orders) and SELL direction(all sell orders) can be calculate and close separately


Trailing Stop at Closing

A new function for trailing profits has been implemented on user demand. That is, a position will not be closed at a fixed level but with a certain adjustment. As soon as the profit reaches the specified value, the Expert Advisor saves the current profit level and starts trailing the profit. If you made settings for closing at the profit of 10 dollars:

If Profit is set to 10 and Trailing Profit is set to 5, the Trailing Stop will be set at 5 dollars. The Trailing Stop will come into play when the Expert Advisor passes the 10 dollar line and start moving following the profit. The Journal will show entries about the current profit status.

10:20:20 Exp - CloseifProfitorLoss wTral EURUSD,H1: Traling is ON tralprofit=12.00000000
10:20:20 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=12.00000000
10:20:20 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=13.00000000
10:20:20 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=13.50000000
10:20:21 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=13.50000000
10:20:23 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=13.50000000
10:20:23 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=14.00000000
10:20:24 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=14.50000000
10:20:24 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=14.50000000
10:20:29 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=15.00000000
10:20:31 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=16.00000000
10:20:32 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=17.50000000
10:20:36 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=18.50000000
10:20:37 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=21.50000000
10:20:37 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=24.00000000
10:20:37 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=24.00000000
10:20:39 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=26.50000000
10:20:39 Exp - CloseifProfitorLoss wTral EURUSD,H1: Level Profit up tralprofit=28.00000000

When the total profit falls below the last fixed level, TralOptions, the Expert Advisor will perform forced closing of all positions:

10:20:42 Exp - CloseifProfitorLoss wTral EURUSD,H1: Close position _close=23.00000000 tralprofit=23.00000000
10:20:43 Exp - CloseifProfitorLoss wTral EURUSD,H1: close #212724663 buy 0.10 EURUSD at 1.34049 at price 1.34095
10:20:44 Exp - CloseifProfitorLoss wTral EURUSD,H1: close #212724661 buy 0.10 EURUSD at 1.34049 at price 1.34094
10:20:45 Exp - CloseifProfitorLoss wTral EURUSD,H1: close #212724660 buy 0.10 EURUSD at 1.34049 at price 1.34095
10:20:45 Exp - CloseifProfitorLoss wTral EURUSD,H1: close #212724658 buy 0.10 EURUSD at 1.34049 at price 1.34095
10:20:46 Exp - CloseifProfitorLoss wTral EURUSD,H1: close #212724657 buy 0.10 EURUSD at 1.34049 at price 1.34094

The use of the Expert Advisor is illustrated with screenshots and the video below.


Share it with friends: