Skip to content

Commit

Permalink
1.09
Browse files Browse the repository at this point in the history
1. Breakeven distance can now be set in currency in addition to points.
2. Equity and margin snapshots can now be made global.
3. Timer can now be made persistent.
4. 'Close all other charts' action.
5. Faster closing of open trades when no filters are selected.
6. Fixed a zero divide issue.
7. Fixed margin level triggering when no trades were open.
8. Fixed a bug with the panel's failure to remember the current tab.
9. Fixed a non-critical error with ArraySort() calls.
10. Added a clarification that the daily % profit/loss conditions are based on the account balance.
  • Loading branch information
EarnForex committed Dec 21, 2022
1 parent b3c3f53 commit 70c0b7d
Show file tree
Hide file tree
Showing 6 changed files with 461 additions and 107 deletions.
15 changes: 13 additions & 2 deletions MQL4/Experts/Account Protector/Account Protector.mq4
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//+------------------------------------------------------------------+
#property copyright "EarnForex.com"
#property link "https://www.earnforex.com/metatrader-expert-advisors/Account-Protector/"
#property version "1.08"
string Version = "1.08";
#property version "1.09"
string Version = "1.09";
#property strict

#property description "Protects account balance by applying given actions when set conditions trigger."
Expand All @@ -22,6 +22,7 @@ input bool PanelOnTopOfChart = true; // PanelOnTopOfChart: Draw chart as backgro
input bool DoNotDisableConditions = false; // DoNotDisableConditions: Don't disable conditions on trigger?
input bool DoNotDisableActions = false; // DoNotDisableActions: Don't disable actions on trigger?
input bool DoNotDisableEquityTS = false; // DoNotDisableEquityTS: Don't disable equity TS on trigger?
input bool DoNotDisableTimer = false; // DoNotDisableTimer: Don't disable timer on trigger?
input bool AlertOnEquityTS = false; // AlertOnEquityTS: Alert when equity trailing stop triggers?
input bool DisableFloatLossRisePerc = false; // Disable floating loss rises % condition.
input bool DisableFloatLossFallPerc = true; // Disable floating loss falls % condition.
Expand Down Expand Up @@ -54,6 +55,8 @@ input bool UseTotalVolume = false; // UseTotalVolume: enable if trading with man
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 CloseMostDistantFirst = false; // CloseMostDistantFirst: Close most distant trades first?
input bool BreakEvenProfitInCurrencyUnits = false; // BreakEvenProfitInCurrencyUnits: currency instead of points.
input bool GlobalSnapshots = false; // GlobalSnapshots: AP instances share equity & margin snapshots.

CAccountProtector ExtDialog;

Expand All @@ -71,12 +74,14 @@ int OnInit()
sets.Timer = TimeToString(TimeCurrent() - 7200, TIME_MINUTES);
sets.TimeLeft = "";
sets.intTimeType = 0;
sets.dtTimerLastTriggerTime = 0;
sets.boolTrailingStart = false;
sets.intTrailingStart = 0;
sets.boolTrailingStep = false;
sets.intTrailingStep = 0;
sets.boolBreakEven = false;
sets.intBreakEven = 0;
sets.doubleBreakEven = 0;
sets.boolBreakEvenExtra = false;
sets.intBreakEvenExtra = 0;
sets.boolEquityTrailingStop = false;
Expand All @@ -86,6 +91,11 @@ int OnInit()
sets.SnapEquityTime = TimeToString(TimeCurrent(), TIME_DATE | TIME_MINUTES | TIME_SECONDS);
sets.SnapMargin = AccountInfoDouble(ACCOUNT_MARGIN_FREE) + AdditionalFunds;
sets.SnapMarginTime = TimeToString(TimeCurrent(), TIME_DATE | TIME_MINUTES | TIME_SECONDS);
if (GlobalSnapshots)
{
SaveGlobalEquitySnapshots();
SaveGlobalMarginSnapshots();
}
sets.OrderCommentary = "";
sets.intOrderCommentaryCondition = 0;
sets.MagicNumbers = "";
Expand Down Expand Up @@ -173,6 +183,7 @@ int OnInit()
sets.DisAuto = false;
sets.EnableAuto = false;
sets.RecaptureSnapshots = false;
sets.CloseAllOtherCharts = false;
sets.SelectedTab = MainTab;

ExtDialog.SilentLogging = true;
Expand Down
Loading

0 comments on commit 70c0b7d

Please sign in to comment.