Loading…

Profit Lockbox Manager

Account balance grows and shrinks together as one number, which makes it easy to unconsciously re-risk gains a trader meant to keep. A trader who decided last month's profit was "banked" has no built-in way to see that decision reflected back at them the next time they are sizing a position - the platform only ever shows one combined balance. This EA watches closed-trade history and, every time a trade closes with a realised gain, banks a configurable percentage of that specific gain into a lockbox reserve. Losses are never drawn from the lockbox - the fraction only accumulates on wins, so it only ever grows or holds steady, never falls. The chart panel reports account balance, the lockbox reserve, and the resulting "tradable capital" figure (balance minus reserve) that a trader can use as the real base for position sizing instead of the full account balance. The lockbox total is persisted with a GlobalVariable keyed to the account number and magic filter, so it survives a chart reload or a terminal restart rather than resetting to zero every time the EA is reattached. Notes and limitations - This EA does not trade and does not restrict anyone from actually spending the "tradable capital" figure - it is a reporting and bookkeeping tool, not an enforcement mechanism. Nothing stops a trader (or another EA) from opening a position larger than the reported tradable capital would suggest. - History scanning uses a ticket-number watermark rather than a timestamp, since MODE_HISTORY pool order is not guaranteed newest-first; this assumes tickets are issued in increasing order by the broker, which is standard but not formally guaranteed by MQL4. - GlobalVariables created with GlobalVariableSet are auto-deleted by the terminal after roughly 4 weeks with no access. A lockbox left completely idle (EA removed, terminal never opened) for over a month can lose its persisted total and silently start again from 0 on next attach - re-attaching periodically avoids this since every GlobalVariableGet/Set call resets that clock. - Balance/credit adjustment entries in history are skipped; only actual closed BUY/SELL orders are counted.

Expert advisor · MT5 · v1.0 · Free

About Profit Lockbox Manager

Profit Lockbox Manager is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Lockbox percent, Magic filter and Reset lockbox. MQL source code included.

Files in the download: ProfitLockboxManager.ex5, ProfitLockboxManager.mq5, ProfitLockboxManager.txt.

Settings

SettingDefaultWhat it does
Lockbox percent25.0Percent of each realised GAIN moved into the lockbox
Magic filter-1Only count closed trades with this magic, -1 = every closed trade
Reset lockboxfalseReset the persisted lockbox total to 0 on this attach
Alert on depositfalsePopup Alert() every time money is added to the lockbox

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria