Profit or Loss Pad
- Utilities
-
Vladislav Andruschenko
👋 Welcome to Expforex
I’m Vladislav, a professional MQL4/MQL5 developer creating MetaTrader tools since 2007.
Expforex develops practical trading solutions for MetaTrader 4 and MetaTrader 5: - Version: 26.526
- Updated: 26 May 2026
- Activations: 10
Close If Profit or Loss with Trailing for MetaTrader 5 — automatic profit and loss control for your trading account
A professional risk-management utility for MetaTrader 5, designed to automatically close positions when the total profit or total loss reaches your predefined level. The Expert Advisor can monitor open trades, calculate floating profit or loss, apply profit trailing, and close positions according to your trading rules.
This is not just a simple close-all script. It is a complete account protection and profit-control tool for traders who want to manage total profit, total loss, drawdown, floating results, and emergency closing logic with more precision than standard MetaTrader tools allow.
Close If Profit or Loss with Trailing can work with manual trading, other Expert Advisors, grid systems, recovery strategies, scalping systems, and portfolio-style trading. It helps automate the most important rule in trading: when the target is reached, the position must be managed without hesitation.
The utility can close trades by profit or loss in deposit currency, points, percent, or drawdown, and can also trail floating profit to secure better results when the market continues moving in your favor.
MT4 version | Full Description + DEMO + PDF | How To Buy | How To Install | How to get Log Files | How To Test and Optimize | All products from Expforex
Why traders use Close If Profit or Loss with Trailing
- Automatic closing by total profit when the account, symbol, direction, or position reaches the target
- Automatic closing by total loss to limit risk and protect the account
- Profit trailing for floating profit after the target level is reached
- Closing by currency, points, percent, or drawdown
- Separate control for BUY and SELL positions
- Separate control for individual positions using virtual stop logic
- Ability to monitor the current symbol or all symbols on the account
- Emergency Close All button for instant manual closing
- Notifications, alerts, and additional protection options
The core idea of the utility
The main purpose of this Expert Advisor is simple: when your total profit or loss reaches the configured value, the utility closes the required positions automatically.
Instead of manually watching every open trade, every symbol, and every floating result, you can define clear profit and loss rules. The Expert Advisor will monitor the market and perform the closing action according to your settings.
This is especially useful when you trade manually, use several Expert Advisors at the same time, manage a basket of trades, work with grid systems, or need account-level protection from excessive floating loss.
As soon as the total result of the selected positions reaches the value specified in the settings, the Expert Advisor can close positions and delete pending orders according to your configuration.
Main capabilities
Close by total profit: close positions when floating profit reaches the target value.
Close by total loss: close positions when floating loss reaches the maximum allowed value.
Profit trailing: after the profit target is reached, the Expert Advisor can trail the floating profit instead of closing immediately.
Flexible calculation modes: profit and loss can be calculated in deposit currency, points, percent, or drawdown.
Symbol control: the utility can work only with the current chart symbol or with all symbols on the account.
Direction control: BUY and SELL positions can be calculated and closed together or separately.
Separate position control: virtual stop logic allows managing positions separately when needed.
Additional protection: pending order deletion, terminal closing, chart closing, FIFO closing, notifications, and alert systems.
How profit trailing works
Profit trailing allows the utility to secure floating profit more intelligently. Instead of closing positions immediately when the profit target is reached, the Expert Advisor can start trailing the total profit.
Example: if the profit target is set to 10 USD and the trailing profit is set to 5 USD, the utility starts monitoring the profit after the floating result reaches 10 USD. If the profit continues to grow, the trailing level moves after it. If the floating profit rolls back by the specified trailing value, the Expert Advisor closes the positions.
This allows the trader to give profitable trades more room while still protecting the achieved result.
Profit trailing is especially useful for basket trading, grid trading, manual position series, and situations where the market can continue moving after the initial profit target is reached.
Working modes
All Symbols mode — monitor and close positions across the entire trading account
- calculate total profit or loss across all symbols
- close all selected positions when the target is reached
- use account-level protection for multi-symbol trading
- delete pending orders after closing if this option is enabled
Current Symbol mode — manage only the symbol where the Expert Advisor is running
- calculate profit or loss only for the current chart symbol
- use separate control for each trading instrument
- run the utility on different charts with different settings
- keep symbol management clean and independent
Separate BUY / SELL mode — manage long and short positions independently
- calculate BUY positions separately from SELL positions
- close only the direction that reached the configured profit or loss
- use separate basket control for opposite trading directions
- improve control when using hedge or recovery strategies
Separate Order mode — virtual stop logic for individual positions
- manage each position separately
- apply virtual profit or loss control to individual trades
- avoid changing broker-side Stop Loss or Take Profit when virtual logic is preferred
- use more flexible trade protection for manual or semi-automatic trading
Usage
- Attach the Expert Advisor to the required MetaTrader 5 chart.
- Select whether the utility should manage the current symbol only or all symbols.
- Choose whether BUY and SELL positions should be calculated together or separately.
- Set a non-zero value for the profit or loss condition you want to use.
- Select the calculation type: currency, points, percent, or drawdown.
- Enable profit trailing if you want to trail floating profit after the target is reached.
- Activate the main Close If Profit or Loss function on the panel.
- When the configured condition is reached, the Expert Advisor will close the selected positions automatically.
Management controls
- All Symbols — enables monitoring and closing across all account symbols
- Current Symbol only — manages only the chart symbol where the utility is attached
- Separate BUY SELL — calculates BUY and SELL positions independently
- Separate Order — enables separate virtual control for individual positions
- Profit $ — close by total profit in deposit currency
- Profit p — close by total profit in points
- Profit % — close by total profit as a percent of balance
- Loss $ — close by total loss in deposit currency
- Loss p — close by total loss in points
- Loss % — close by total loss as a percent of balance
- Close If Profit or Loss ON / OFF — enables or disables the automatic closing logic
- Close All — instantly closes all selected positions manually
Real trading advantages
- removes the need to constantly watch floating profit and loss manually
- helps protect the account from excessive floating drawdown
- locks trading discipline into automatic execution rules
- works together with manual trading and other Expert Advisors
- helps manage grids, baskets, recovery systems, and multi-symbol trading
- can close positions faster than manual reaction in critical situations
- adds structured profit-control logic to MetaTrader 5
Who this utility is for
- manual traders who want automatic profit and loss control
- traders using several positions at the same time
- grid and basket traders
- traders who work with recovery or averaging systems
- users of other Expert Advisors who need external account protection
- traders who want to close by total profit instead of individual Take Profit levels
- traders who want a simple but powerful risk-management assistant
The utility can work on any account type and with any broker that supports standard MetaTrader 5 trading operations. It can be used together with manual trading, other Expert Advisors, and different trading systems. The result always depends on broker execution, symbol specification, spread, commission, slippage, and market conditions.
Important notes
- The Expert Advisor does not predict market direction.
- The utility does not replace a trading strategy.
- The main purpose is trade management, profit control, and risk limitation.
- Always test your settings on a demo account before using them on a real account.
- For reliable work, use a stable VPS and check your broker’s trading conditions.
External variables and settings
Notifications: enable phone notifications, sound alerts, and messages about trading actions or errors.
Language: select the interface language or use the terminal language by default.
MagicNumber: define which positions should be managed by the Expert Advisor. A value of 0 can be used when working without a specific magic number.
UseAllMagicFromAllAccount: allows the utility to monitor positions regardless of their magic number, depending on your selected mode.
Show_Future_BE_TP_SL: displays future break-even, profit, and loss levels on the chart for visual control.
CLP_TralOptionsStep: defines the step used for adjusting trailing profit values.
Use_Commission_in_CLP: includes commission in profit and loss calculations.
AutoCorrect_LevelCLP: automatically corrects invalid profit or loss values when necessary.
CLP_DeleteStopOrders: deletes pending orders after closing positions according to the selected rules.
Use_Lots_in_CLP_Points: considers lot size when calculating profit or loss in points.
CPL_CloseAllCharts_per_CloseAllDeals: closes charts with the Expert Advisor before closing positions when this function is enabled.
CPL_CloseTerminalAfterClose: closes the MetaTrader terminal after all selected positions are closed.
ShowCloseAllButton: displays the emergency Close All button on the panel.
ClosingCurrentTicketOnly: manages only the current list of tickets and ignores new positions opened later by other systems.
ClosebyFIFO: closes positions according to FIFO logic when required.
VPS_CLP_Activation: enables special CLP parameter control for VPS environments.
LimitFor: sets the period for checking trading limits.
LimitForLosses / LimitForProfits: defines profit and loss limits for alerts and control logic.
LimitForLotsDeals / LimitForCountDeals: sets limits for lot size and number of deals.
TypeFilling: defines the order filling type for MetaTrader 5. AUTO allows the Expert Advisor to determine the correct filling mode automatically.
Additional recommendations
If you need a complete professional trading panel with manual trading, order management, chart trading, keyboard trading, signals, and CLP tools, I recommend VirtualTradePad for MetaTrader 5.
If you want to learn how to work in the strategy tester, take a look at our free utility TesterPad.
Tags: Expforex, Vladon, Close If Profit or Loss, CloseIfProfitorLoss, CLP, Profit Trailing, Trailing Profit, Smart Trailing Stop, Close Profit, Close Loss, Total Profit, Total Loss, Drawdown Control, Risk Manager, MetaTrader 5 Utility, MT5 Trade Manager, Forex Utility, Forex Risk Management, Account Protection, Basket Trading, Grid Trading, Manual Trading, Expert Advisor, Trade Management, Close All, Virtual Stop Loss, Virtual Take Profit


I can't thank Vladislav enough for their tool and their patience in upgrading it to meet my needs. They were incredibly helpful and professional throughout the process. Thank you so much for your assistance!