Capital SL Defender Pro
- Yardımcı programlar
-
Michael Ngugi Michuki
I am a Forex Trader from Kenya, with a background in software engineering. I love trading and I want to create solutions for the trading space to make it less painful and more productive - Sürüm: 3.5
- Etkinleştirmeler: 5
Capital SL Defender Pro is a position manager and profit protection Expert Advisor for MetaTrader 5. It does not look for trades. You (or another EA) open the trades, and Capital SL Defender Pro manages them: it sets the stop loss and take profit the moment a trade opens, moves the stop to break-even once the trade is a quarter of the way to its target, can protect small wins from turning into losses, closes trades only at limits you switch on, and shows everything on a black and orange panel on the chart.
It runs on its own, with no outside service, web address or token. You choose which trades it manages: the chart's symbol or every symbol, and every trade (the default), manual trades only or one EA's trades.
1What it does
| Area | What Capital SL Defender Pro does |
|---|---|
| Auto SL/TP | Adds a stop loss and take profit to any trade opened without them, the moment it opens. By default the SL is 1000 points from entry (100 index points on indices such as US30) and the TP three times as far (1:3). You can use % of balance, % of price or a dollar risk per trade instead. |
| Profit lock by % of TP | Moves the SL to break-even at 25% of the way to TP, then locks 25% more of the TP distance at each further step (50%, 75%...). The SL never moves backward. |
| Break-even | Once a trade has run 10% of the way to its TP, it can no longer close at a loss: the SL moves to entry plus a few pips, or the trade is closed if price is already back there. While it is on it is the only break-even: the profit lock and the classic break-even leave that step to it. |
| TP runner | Near the TP, the EA removes it, locks most of the move and keeps trailing, so a trade that keeps pushing keeps paying. |
| Trailing and classic managers | Trailing stop (with optional dynamic widening and its own panel switch, green while it trails), dollar/pip break-even, profit lock-in and trail without TP, for trades without a TP or with the profit lock off. All off by default. |
| Entry lock | A daily limit on new trades, an on/off Trading switch, a pause after a stop-out, a position cap and a daily loss cap. By default it counts and shows; with EnforceEntryLock on, a trade opened while entries are locked is closed straight away. |
| Hard exits | Per-trade max loss (dollars or pips), per-trade profit target, max hold time, closes before session ends and daily loss caps. All off by default. |
| Dashboard | Black and orange panel: account, risk setup (what a trade of your lot size risks, in dollars, % of balance, points and % of price), on/off switches for each protection, the next news event, and every managed trade with its progress to TP and its next SL step (with a countdown where the step is time-based). A SETTINGS button opens a settings panel on the chart. |
| Session lines | Sydney, Asian, London and New York sessions drawn as thick lines with a named marker box, for today and up to 30 days back, in your own time zone. |
| News filter (optional) | Reads MT5's built-in economic calendar and pauses SL changes and new entries around high-impact events. A pop-up alert warns before each one (on by default, works with the blackout off too). |
2Requirements
- MetaTrader 5 (any broker, demo or live).
- Algo Trading turned on in the MT5 toolbar.
Nothing else: no web address to allow, no token, no DLLs.
3Installation
From the MQL5 Market: after purchase, Capital SL Defender Pro appears in the Navigator under Expert Advisors → Market. Go to step 3 below.
From the source file ( CapitalSLDefenderPro.mq5 ):
- In MT5, open File → Open Data Folder and copy the file into MQL5/Experts/ .
- Open it in MetaEditor (F4) and compile (F7). The result should read 0 errors, 0 warnings .
- Turn on Algo Trading in the toolbar (the button must be green).
- Drag Capital SL Defender Pro onto a chart.
- In the Common tab tick Allow Algo Trading, then set your inputs (section 4) and click OK.
One copy or several. One copy manages the trades its scope covers (section 10). By default that is every trade on the chart's symbol, so trading three symbols means attaching it to three charts, or setting ManageScope to every symbol on one chart. Don't let two copies manage the same trades. Each copy keeps its own entry count, pause and panel switches.
4Quick start
These are the inputs most traders change. Everything else can stay at its default. The Inputs tab shows each input's label; section 12 lists the label next to each input name used here.
- Which trades to manage: ManageScope (this chart's symbol, or every symbol) and MagicNumberFilter ( -1 = every trade, the default; 0 = trades you open by hand; or another EA's magic number).
- Auto SL/TP: trades opened without one
- SLTPMode : leave on Classic points.
- AutoSLPoints : the SL distance, 1000 points (10.00 on 2-decimal gold, 100 pips on EURUSD). Indices such as US30 use IndexSLPoints instead, 100 whole index points (section 7.1).
- RiskRewardRatio : the TP as a multiple of the SL distance, 3 (that is 1:3: 3000 points, or 300 index points).
- SetLotSize : the lot size you usually trade. The dashboard shows what a trade of that size risks in money.
- Break-even: turn on for an early break-even at 10% of the way to TP (entry + 2 pips). It is then the only break-even.
- Profit lock: leave on. Break-even at 25% of the way to TP (skipped while Break-even is on), then 25% more of the TP distance locked at each further 25%.
- Entry limits: MaxEntriesPerDay (10, 0 = no limit). Session times: SessionTimeZone and the session times in your zone (section 6).
- Click OK. The dashboard appears at the bottom-left and the session lines are drawn.
Then open a small trade on a demo account with no SL/TP and watch the dashboard: the SL and TP appear as soon as the trade opens, and the trade's line shows how far it is to TP and where the SL sits.
Most of these can also be changed later without opening the inputs: click SETTINGS on the dashboard (section 7.3).
5The dashboard
The panel sits at the bottom-left of the chart by default. It can go on either side, at the top or the bottom, and updates once a second.
| Input | Choices |
|---|---|
| DashboardSide | Left or Right. On the right it follows the chart edge when you resize. |
| DashboardVertical | Bottom (default): the panel's base sits on the chart's bottom edge and it grows upward as trades open. Top: it hangs from the top, below MT5's one-click Buy/Sell panel when that is showing. |
| DashboardSize | Large: everything below. Small: the same content, smaller. Tiny: a business-card summary. |
| DashboardX , DashboardTopY | Distance from the chart edge, and the panel's top edge, in pixels. DashboardTopY = 0 places it automatically. At the bottom, DashboardTopY is the highest the panel reaches. |
| DashboardAccentColor , DashboardBackColor | Orange and black by default. |
Text sizes follow your Windows display scaling. Anything too long for its row is shortened with .. instead of overlapping.
Header: the product name, version, a fold button (▼ / ▲) and a SESSIONS ON/OFF button. Click SESSIONS to show or hide the session lines on the spot.
Fold. Click ▼ to fold the panel down to the status line and ACCOUNT, so you can see more of the chart. The folded panel always drops to the bottom corner of its side, even when the panel is set to the top. Click ▲ to open it again in its usual place. The fold is remembered through timeframe changes and MT5 restarts.
Side and position from the chart. The settings panel's Panel side (Left/Right) and Panel anchor (Top/Bottom) rows move the dashboard without opening the inputs (section 7.3).
Scrolling. On a small screen, or with many trades open, the panel can be taller than the chart. It is then cut to the chart's height and an orange scrollbar appears on its right edge. Turn the mouse wheel over the panel, or click the scrollbar above or below its thumb, to scroll. The header stays in place. While the pointer is over the panel the chart doesn't scroll with it.
Status line: PROTECTING (green) while algo trading is allowed, ALGO TRADING OFF (red) when the toolbar button or the EA's Allow Algo Trading box is off. On the right: what it manages (for example XAUUSD, every trade ) and the time in your selected time zone.
| Section | Rows |
|---|---|
| Account | A SETTINGS button on the section's title row (section 7.3), then balance, equity, floating P/L of the whole account (equity minus balance), today's net P/L of the managed trades (closed trades with commission and swap, plus open trades; deposits and withdrawals are not counted), entries today against your daily limit, and the Next news switch with the next high-impact event (counting down in its last hour). A red Not managed row lists open trades outside the scope (section 10), for example 1 trade: magic 24 . Open risk at SLs: what the open trades lose if all hit their SL, against MaxOpenRiskPercent when it is set (section 7.4). |
| Risk setup | What a trade of your lot size ( SetLotSize , or the lot size typed on the settings panel) would risk: the lot size, how the SL/TP is set, Risk at SL in dollars and % of balance, SL distance in points and % of price, Target at TP and TP distance the same way, reward:risk, and the Auto SL/TP switch. Change the lot size and these update straight away, even with a trade open. With the risk guard on (section 7.4), Lot for 1% risk shows the lot that fits a stop clear of normal noise, and Lot too large warns when your lot's stop would sit inside it. |
| Protection | Switches for Break-even, Profit lock, Trailing stop, TP runner and Trading (below), and the open sessions. |
| Positions | Up to 5 managed trades, up to three lines each: symbol, side, lots and P/L; then progress to TP and the SL state ( SL +25% locked , SL +$12.40 locked for a trade without a TP, SL at break-even , or the dollars and % of balance still at risk); then, in orange, the next step for its SL and what it waits for: Next: Break-even at 4123.06 (+1.24) (the price, and how far price still has to go), Next: Lock +25% at 4131.06 (+5.24) , Next: Trailing at 4141.66 (+15.84) , Next: Trailing in 3:12 (the wait after break-even, counting down), Next: Trailing 5 pips behind , or Next: Runner at 4140.06 (+14.24) . With MaxHoldMinutes set it adds Close in 42:10 ; during a news blackout it starts Paused for news: . A runner (section 8.3) shows its progress against the TP it had before the EA removed it, for example 132% of TP, runner . |
Switches. Auto SL/TP, Next news, Break-even, Profit lock, Trailing stop, TP runner and Trading are buttons. Click one to switch it on or off on the spot, without opening the settings.
| Switch | On | Off |
|---|---|---|
| Auto SL/TP | Orange ON : trades opened without SL/TP get them | Grey, OFF : new trades are left as they are |
| Break-even, Profit lock, TP runner | Orange, showing the plan it runs (for example @10% of TP, SL entry +2 pips ; BE @25%, +25% per step , or from 25%, +25% per step while Break-even does the break-even) | Grey, OFF |
| Trailing stop | Orange Waiting, from +0.50% until a trade reaches the start; green ACTIVE on 1 trade while it trails | Grey, OFF |
| Trading | Green ACTIVE , or orange/red while a limit is locking entries | Grey, INACTIVE : new trades are locked out (section 9) |
| Next news | Orange, showing the next high-impact event (or None upcoming ); the news blackout is on | Grey: the blackout is off. It still shows the next event while the pop-up alert is on, OFF when both are off |
- Each switch starts from its input ( EnableAutoTPSL , EnableNewsFilter , EnableScalperProtection , EnableTPProgressLock , EnableTrailingSL , EnableTPRunner ). A click is remembered through timeframe changes and MT5 restarts.
- Clicks are kept through timeframe changes, MT5 restarts and removing and re-attaching the EA. Editing an input in the Inputs window replaces only that input's switch: changing, say, the trailing stop leaves a profit lock you switched off from the panel off. Trading stays as you left it, except that re-attaching the EA starts it ON.
- INACTIVE only locks out new trades. Open trades keep their SL management and hard exits.
- Switching the TP runner off doesn't affect trades that are already runners; they stay runners until they close.
Trading status values: ACTIVE , INACTIVE (switched off on the panel), PAUSED n min (after a max-loss close), Entry limit reached , Max positions open , News blackout , HALTED - daily loss limit . Anything other than ACTIVE means a new managed trade would be closed as it opens when EnforceEntryLock is on (section 9).
Tiny shows only: status and clock, the SETTINGS button, balance, equity, today's P/L, the Not managed row when there are any, the number of managed trades with their combined P/L, and trading status.
When the dashboard is on, it replaces the plain-text chart comment. Set ShowDashboard = false to get the text version back.
6Session lines and time zones
Each session gets a thick line at its open and close in its own colour, and a coloured box at the top of the chart that spans the session and shows its name and hours. Overlapping sessions stack their boxes. The boxes stay at the top when you scroll or zoom. Lines are hidden on D1 and higher, where sessions mean nothing.
- Today and earlier days. The trading day rolls over when the Asian session opens, so the overnight sessions belong to the day they lead into. On Saturday and Sunday, Friday's sessions stay up. SessionHistoryDays (default 10, up to 30) also draws the same sessions on earlier weekdays; 0 draws today only. Earlier days use today's broker time offset, so days before a daylight-saving change can sit an hour off.
- Fewer objects on short timeframes. With SessionHistoryAutoLimit on (default), M1 to M15 draw only back to the leftmost bar on screen. Scroll back or zoom out and more days appear, up to SessionHistoryDays . 30 days is about 350 chart objects, which MT5 handles easily.
- Marker text that fits. A marker shows the longest text that fits inside its box at the current zoom: the name and hours, the name, then a short name (SYD, ASIA, LDN, NY), or nothing when even that does not fit (hover over the box for the full name). From HideTimesFromTF (M15) up it never shows the hours. Hover over a marker for its full times.
- Show or hide: EnableSessionLines sets the starting state; the SESSIONS button on the panel switches them on and off without opening the settings. Switching timeframe keeps your choice.
- Colours: Sydney green, Asian purple, London blue, New York black by default. Black is invisible on a black chart, so change NewYorkSessionColor if you use one.
- Thickness and style: SessionLineWidth 1–5 (default 3). MT5 only draws dashed and dotted lines at width 1, so SessionLineStyle has no effect at the default width.
Time zones
Pick the zone you think in with SessionTimeZone and type every session time in that zone. You never need to work out your broker's server offset.
Choices: UTC; UTC+1, +2, +3, +4, +5:30, +8, +9, +10; UTC-4, UTC-5; broker server time; this computer's clock. The fixed offsets do not move with daylight saving. If your local clock changes in summer, choose this computer's clock or update the offset twice a year.
The marker boxes, tooltips and dashboard clock all show times in your zone with its label, for example London 09:00-17:00 UTC+3 . Session-end closes (section 9) use the same zone.
| Session | UTC (default) | UTC+3 (e.g. Nairobi) |
|---|---|---|
| Sydney | 22:00 – 07:00 | 01:00 – 10:00 |
| Asian | 21:00 – 06:00 | 00:00 – 09:00 |
| London | 06:00 – 14:00 | 09:00 – 17:00 |
| New York | 12:00 – 21:00 | 15:00 – 00:00 |
