CustomStopOut is a script that puts your own margin call and stop-out levels on top of your broker's. Attach it to any chart and it checks the account every half second until you remove it. When the margin level falls below your margin call level, it alerts you. When it falls below your stop-out level, it does what the broker does at its own stop-out, only earlier: it closes the open position with the worst result, reads the margin level again, and closes the next one only if the level is still too low.
A broker's stop-out at 20% or 50% often comes too late and takes the whole account with it. With this script you choose the level, for example 100%, and keep the positions that are still fine.
| Input | Default | Meaning |
|---|---|---|
| Margin call level, % | 150 | Alert below this margin level |
| Stop-out level, % | 100 | Close the worst position below this margin level |
| Check interval, milliseconds | 500 | Time between checks |
| Positions to close | All symbols | All symbols or the chart symbol only |
| Magic number to close | -1 | One magic number, or -1 for any |
| Maximum slippage on a close, points | 30 | Slippage allowed when closing |
| Alert window, Push notification, Sound | on, off, off | Where the alerts go |
The script will not start with levels that cannot work, and says why in an alert:
not started reason="stop-out level 100.00% must be below the margin call level 100.00%" not started reason="stop-out level 50.00% must be above the broker's stop-out level 50.00%, or the broker closes first"
The broker's levels are read from the account. Some brokers set them as an amount of money instead of a percentage; then there is no fixed margin level to compare with, so the script says so in the Experts tab and works on your percent levels alone.
Every alert is also printed to the Experts tab:
started version=1.0 margin_call=150.00% stop_out=100.00% broker_margin_call=100.00% broker_stop_out=40.00% symbols=all magic=any interval_ms=500 margin call margin_level=140.00% call_level=150.00% closed ticket=123456789 symbol=EURUSD side=buy lots=0.1 net=-44.40 USD margin_level_before=96.10% margin_level_after=118.30% close refused ticket=123456789 symbol=EURUSD side=buy lots=0.1 err=10018 desc="Market closed" stopped closed=1
The picture is a real run on a demo account, with both levels set far above the account's margin level so the script had to close a small test position.
Keep the terminal running and connected: the script acts only while it runs. Algo trading must be allowed for it to close positions; without it, it still alerts and tells you at start that closes will be refused.
Currency Strength Free MT5 - Eight Currency Scanner
Free MT5 dashboard comparing eight major-currency strengths and ranking up to 28 FX pairs from completed candles. Includes broker-prefix/suffix detection, synchronization checks, chart navigation and eight output buffers. Independent MIT-licensed source; no trading operations.
StrictJson: RFC 8259 JSON parser and writer for MQL5
One include file that reads and writes JSON in MQL5 and MQL4. It refuses broken JSON and tells you the line and column of the mistake, keeps numbers exact, reads and writes UTF-8 files, and saves your EA's settings to a file and loads them back.
Accelerator Oscillator (AC)
The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.
MACD Signals
Indicator edition for new platform.