Skip to content

Commit 6010178

Browse files
author
EarnForex
authored
1.12
1. Added an option to connect conditions ticked on the Conditions tab with logical AND (WaitForAllConditions). This means that you can make the Account Protector react only when all the selected conditions are met, not just one of them. 2. Added an option to connect Account Protectors using a signal action/condition. 3. Added display of the daily opening balance for daily profit/loss percentage conditions. 4. Added input parameters to disable any condition. 5. Added conditions based on the current account balance. 6. Added an option to execute orders in asynchronous mode in MT5 (AsyncMode). 7. Added an input parameter to make the EA disable autotrading when equity trailing stop is hit (DisableAutoTradingOnTS). 8. Added informative tooltips to most panel elements. 9. Added an option to modify the Emergency button's behavior. If CloseOtherChartsOnEmergencyButton is set to true, the button will close all other charts instead of disabling autotrading. 10. Added logging of order execution results in MT5. 11. Changed the order of actions triggering to make sure that Close all other charts takes priority. 12. Changed how the positions closed via the Close action are filtered by profit/loss. They now ignore the profitable/losing options from the Filters tab and instead use the respective action setting. 13. Changed how conditions are logged to avoid logging disabled conditions. 14. Fixed initial daily balance calculation for cases when CountFloatingInDailyPL is set to true. 15. Fixed log file name to be exactly the same as given via the LogFileName input parameter. 16. Fixed a bug when the bottom condition on the Conditions tab could get overwritten by another condition (if enabled via input parameters). 17. Fixed a bug with commission calculation in MT5. 18. Fixed descriptions of some conditions.
1 parent ef6485a commit 6010178

File tree

6 files changed

+1857
-897
lines changed

6 files changed

+1857
-897
lines changed

MQL4/Experts/Account Protector/Account Protector.mq4

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//+------------------------------------------------------------------+
22
//| Account Protector.mq4 |
3-
//| Copyright © 2017-2024, EarnForex.com |
3+
//| Copyright © 2017-2025, EarnForex.com |
44
//| https://www.earnforex.com/ |
55
//+------------------------------------------------------------------+
66
#property copyright "EarnForex.com"
77
#property link "https://www.earnforex.com/metatrader-expert-advisors/Account-Protector/"
8-
#property version "1.11"
9-
string Version = "1.11";
8+
#property version "1.12"
9+
string Version = "1.12";
1010
#property strict
1111

1212
#property description "Protects account balance by applying given actions when set conditions trigger."
@@ -38,34 +38,48 @@ input bool DisableFloatProfitRisePoints = false; // Disable floating profit rise
3838
input bool DisableFloatProfitFallPoints = true; // Disable floating profit falls points condition.
3939
input bool DisableCurrentPriceGE = true; // Disable current price greater or equal condition.
4040
input bool DisableCurrentPriceLE = true; // Disable current price less or equal condition.
41+
input bool DisableEquityUnitsLE = false; // Disable equity less or equal currency units condition.
42+
input bool DisableEquityUnitsGE = false; // Disable equity greater or equal currency units condition.
43+
input bool DisableEquityPercLE = false; // Disable equity less or equal % of snapshot condition.
44+
input bool DisableEquityPercGE = false; // Disable equity greater or equal % of snapshot condition.
4145
input bool DisableEquityMinusSnapshot = true; // Disable (Equity - snapshot) greater or equal condition.
4246
input bool DisableSnapshotMinusEquity = true; // Disable (snapshot - Equity) greater or equal condition.
47+
input bool DisableMarginUnitsLE = false; // Disable free margin less or equal currency units condition.
48+
input bool DisableMarginUnitsGE = false; // Disable free margin greater or equal currency units condition.
49+
input bool DisableMarginPercLE = false; // Disable free margin less or equal % of snapshot condition.
50+
input bool DisableMarginPercGE = false; // Disable free margin greater or equal % of snapshot condition.
4351
input bool DisableMarginLevelGE = true; // Disable margin level greater or equal condition.
4452
input bool DisableMarginLevelLE = true; // Disable margin level less or equal condition.
4553
input bool DisableSpreadGE = true; // Disable spread greater or equal condition.
4654
input bool DisableSpreadLE = true; // Disable spread less or equal condition.
4755
input bool DisableDailyProfitLossUnitsGE = true; // Disable daily profit/loss greater or equal units condition.
48-
input bool DisableDailyProfitLossUnitsLE = true; // Disable daily profit/loss level less or equal units condition.
56+
input bool DisableDailyProfitLossUnitsLE = true; // Disable daily profit/loss less or equal units condition.
4957
input bool DisableDailyProfitLossPointsGE = true; // Disable daily profit/loss greater or equal points condition.
50-
input bool DisableDailyProfitLossPointsLE = true; // Disable daily profit/loss level less or equal points condition.
58+
input bool DisableDailyProfitLossPointsLE = true; // Disable daily profit/loss less or equal points condition.
5159
input bool DisableDailyProfitLossPercGE = true; // Disable daily profit/loss greater or equal percentage condition.
52-
input bool DisableDailyProfitLossPercLE = true; // Disable daily profit/loss level less or equal percentage condition.
60+
input bool DisableDailyProfitLossPercLE = true; // Disable daily profit/loss less or equal percentage condition.
5361
input bool DisableNumberOfPositionsGE = true; // Disable number of positions greater or equal condition.
5462
input bool DisableNumberOfOrdersGE = true; // Disable number of pending orders greater or equal condition.
5563
input bool DisableNumberOfPositionsLE = true; // Disable number of positions less or equal condition.
5664
input bool DisableNumberOfOrdersLE = true; // Disable number of pending orders less or equal condition.
65+
input bool DisableBalanceGE = true; // Disable balance greater or equal condition.
66+
input bool DisableBalanceLE = true; // Disable balance less or equal condition.
67+
input bool DisableListenToSignal = true; // Disable signal condition.
68+
input bool WaitForAllConditions = false; // WaitForAllConditions: Only trigger when all conditions are met.
5769
input string ____Trading = "";
5870
input int DelayOrderClose = 0; // DelayOrderClose: Delay in milliseconds.
5971
input bool UseTotalVolume = false; // UseTotalVolume: enable if trading with many small trades and partial position closing.
6072
input ENUM_CLOSE_TRADES CloseFirst = ENUM_CLOSE_TRADES_DEFAULT; // CloseFirst: Close which trades first?
6173
input bool BreakEvenProfitInCurrencyUnits = false; // BreakEvenProfitInCurrencyUnits: currency instead of points.
6274
input bool EquityTrailingStopInPercentage = false; // EquityTrailingStopInPercentage: % instead of $.
75+
input bool DisableAutoTradingOnTS = false; // DisableAutoTradingOnTS: Disable autotrading on eq. TS trigger.
6376
input string ____Miscellaneous = "";
6477
input bool AlertOnEquityTS = false; // AlertOnEquityTS: Alert when equity trailing stop triggers?
6578
input double AdditionalFunds = 0; // AdditionalFunds: Added to balance, equity, and free margin.
6679
input string Instruments = ""; // Instruments: Default list of trading instruments for order filtering.
6780
input bool GlobalSnapshots = false; // GlobalSnapshots: AP instances share equity & margin snapshots.
6881
input int Slippage = 2; // Slippage
82+
input bool CloseOtherChartsOnEmergencyButton = false; // Close other charts on emergency button.
6983
input string LogFileName = "ap_log.txt"; // Log file name
7084
input string SettingsFileName = ""; // Settings file: Load custom panel settings from \Files\ folder.
7185
input bool Silent = false; // Silent: No log output to the Experts tab.
@@ -169,6 +183,9 @@ int OnInit()
169183
sets.boolNumberOfOrdersGE = false;
170184
sets.boolNumberOfPositionsLE = false;
171185
sets.boolNumberOfOrdersLE = false;
186+
sets.boolBalanceGE = false;
187+
sets.boolBalanceLE = false;
188+
sets.boolListenToSignal = false;
172189
sets.doubleLossPerBalance = 0;
173190
sets.doubleLossQuanUnits = 0;
174191
sets.intLossPoints = 0;
@@ -207,6 +224,9 @@ int OnInit()
207224
sets.intNumberOfOrdersGE = 0;
208225
sets.intNumberOfPositionsLE = 0;
209226
sets.intNumberOfOrdersLE = 0;
227+
sets.doubleBalanceGE = 0;
228+
sets.doubleBalanceLE = 0;
229+
sets.intListenToSignal = 0;
210230
sets.ClosePos = true;
211231
sets.doubleClosePercentage = 100;
212232
sets.CloseWhichPositions = All;

0 commit comments

Comments
 (0)