Skip to content

Commit

Permalink
1.12
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EarnForex authored Jan 16, 2025
1 parent ef6485a commit 6010178
Show file tree
Hide file tree
Showing 6 changed files with 1,857 additions and 897 deletions.
32 changes: 26 additions & 6 deletions MQL4/Experts/Account Protector/Account Protector.mq4
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//+------------------------------------------------------------------+
//| Account Protector.mq4 |
//| Copyright © 2017-2024, EarnForex.com |
//| Copyright © 2017-2025, EarnForex.com |
//| https://www.earnforex.com/ |
//+------------------------------------------------------------------+
#property copyright "EarnForex.com"
#property link "https://www.earnforex.com/metatrader-expert-advisors/Account-Protector/"
#property version "1.11"
string Version = "1.11";
#property version "1.12"
string Version = "1.12";
#property strict

#property description "Protects account balance by applying given actions when set conditions trigger."
Expand Down Expand Up @@ -38,34 +38,48 @@ input bool DisableFloatProfitRisePoints = false; // Disable floating profit rise
input bool DisableFloatProfitFallPoints = true; // Disable floating profit falls points condition.
input bool DisableCurrentPriceGE = true; // Disable current price greater or equal condition.
input bool DisableCurrentPriceLE = true; // Disable current price less or equal condition.
input bool DisableEquityUnitsLE = false; // Disable equity less or equal currency units condition.
input bool DisableEquityUnitsGE = false; // Disable equity greater or equal currency units condition.
input bool DisableEquityPercLE = false; // Disable equity less or equal % of snapshot condition.
input bool DisableEquityPercGE = false; // Disable equity greater or equal % of snapshot condition.
input bool DisableEquityMinusSnapshot = true; // Disable (Equity - snapshot) greater or equal condition.
input bool DisableSnapshotMinusEquity = true; // Disable (snapshot - Equity) greater or equal condition.
input bool DisableMarginUnitsLE = false; // Disable free margin less or equal currency units condition.
input bool DisableMarginUnitsGE = false; // Disable free margin greater or equal currency units condition.
input bool DisableMarginPercLE = false; // Disable free margin less or equal % of snapshot condition.
input bool DisableMarginPercGE = false; // Disable free margin greater or equal % of snapshot condition.
input bool DisableMarginLevelGE = true; // Disable margin level greater or equal condition.
input bool DisableMarginLevelLE = true; // Disable margin level less or equal condition.
input bool DisableSpreadGE = true; // Disable spread greater or equal condition.
input bool DisableSpreadLE = true; // Disable spread less or equal condition.
input bool DisableDailyProfitLossUnitsGE = true; // Disable daily profit/loss greater or equal units condition.
input bool DisableDailyProfitLossUnitsLE = true; // Disable daily profit/loss level less or equal units condition.
input bool DisableDailyProfitLossUnitsLE = true; // Disable daily profit/loss less or equal units condition.
input bool DisableDailyProfitLossPointsGE = true; // Disable daily profit/loss greater or equal points condition.
input bool DisableDailyProfitLossPointsLE = true; // Disable daily profit/loss level less or equal points condition.
input bool DisableDailyProfitLossPointsLE = true; // Disable daily profit/loss less or equal points condition.
input bool DisableDailyProfitLossPercGE = true; // Disable daily profit/loss greater or equal percentage condition.
input bool DisableDailyProfitLossPercLE = true; // Disable daily profit/loss level less or equal percentage condition.
input bool DisableDailyProfitLossPercLE = true; // Disable daily profit/loss less or equal percentage condition.
input bool DisableNumberOfPositionsGE = true; // Disable number of positions greater or equal condition.
input bool DisableNumberOfOrdersGE = true; // Disable number of pending orders greater or equal condition.
input bool DisableNumberOfPositionsLE = true; // Disable number of positions less or equal condition.
input bool DisableNumberOfOrdersLE = true; // Disable number of pending orders less or equal condition.
input bool DisableBalanceGE = true; // Disable balance greater or equal condition.
input bool DisableBalanceLE = true; // Disable balance less or equal condition.
input bool DisableListenToSignal = true; // Disable signal condition.
input bool WaitForAllConditions = false; // WaitForAllConditions: Only trigger when all conditions are met.
input string ____Trading = "";
input int DelayOrderClose = 0; // DelayOrderClose: Delay in milliseconds.
input bool UseTotalVolume = false; // UseTotalVolume: enable if trading with many small trades and partial position closing.
input ENUM_CLOSE_TRADES CloseFirst = ENUM_CLOSE_TRADES_DEFAULT; // CloseFirst: Close which trades first?
input bool BreakEvenProfitInCurrencyUnits = false; // BreakEvenProfitInCurrencyUnits: currency instead of points.
input bool EquityTrailingStopInPercentage = false; // EquityTrailingStopInPercentage: % instead of $.
input bool DisableAutoTradingOnTS = false; // DisableAutoTradingOnTS: Disable autotrading on eq. TS trigger.
input string ____Miscellaneous = "";
input bool AlertOnEquityTS = false; // AlertOnEquityTS: Alert when equity trailing stop triggers?
input double AdditionalFunds = 0; // AdditionalFunds: Added to balance, equity, and free margin.
input string Instruments = ""; // Instruments: Default list of trading instruments for order filtering.
input bool GlobalSnapshots = false; // GlobalSnapshots: AP instances share equity & margin snapshots.
input int Slippage = 2; // Slippage
input bool CloseOtherChartsOnEmergencyButton = false; // Close other charts on emergency button.
input string LogFileName = "ap_log.txt"; // Log file name
input string SettingsFileName = ""; // Settings file: Load custom panel settings from \Files\ folder.
input bool Silent = false; // Silent: No log output to the Experts tab.
Expand Down Expand Up @@ -169,6 +183,9 @@ int OnInit()
sets.boolNumberOfOrdersGE = false;
sets.boolNumberOfPositionsLE = false;
sets.boolNumberOfOrdersLE = false;
sets.boolBalanceGE = false;
sets.boolBalanceLE = false;
sets.boolListenToSignal = false;
sets.doubleLossPerBalance = 0;
sets.doubleLossQuanUnits = 0;
sets.intLossPoints = 0;
Expand Down Expand Up @@ -207,6 +224,9 @@ int OnInit()
sets.intNumberOfOrdersGE = 0;
sets.intNumberOfPositionsLE = 0;
sets.intNumberOfOrdersLE = 0;
sets.doubleBalanceGE = 0;
sets.doubleBalanceLE = 0;
sets.intListenToSignal = 0;
sets.ClosePos = true;
sets.doubleClosePercentage = 100;
sets.CloseWhichPositions = All;
Expand Down
Loading

0 comments on commit 6010178

Please sign in to comment.