Peak Gain Giveback Guard
- Yardımcı programlar
- Sürüm: 1.0
- Etkinleştirmeler: 5
See it work before you trust it: load Peak Gain Giveback Guard into the Strategy Tester, switch on visual mode and watch the giveback meter fill as a demo trade slides back from its best price, then see step 1 bank half of it and step 2 take the rest.
A WINNING TRADE SHOULD NEVER BE ALLOWED TO WALK ALL THE WAY BACK TO A LOSS.
Peak Gain Giveback Guard is a utility Expert Advisor for MetaTrader 5. It does not search for entries and it does not open trades for you. It remembers the best open profit each of your trades has reached, its peak, and the moment a trade hands back a percentage of that peak that you decided in advance, it banks part of the position. If the slide continues, it closes the rest. You choose how much you are willing to give back; the utility makes sure you never give back more.
At a glance
• A personal peak for every position in scope, measured in points or in money after swap.
• Two exit steps on a percentage of that peak: step 1 closes part of the volume, step 2 closes what is left.
• A safety floor that takes out the remaining volume if profit after step 1 falls close to zero.
• A confirmation delay so a single tick of noise cannot trigger an exit.
• Peak memory: peaks and steps survive a terminal restart, a profile change or a chart switch.
• A giveback meter for the worst trade and a BACK percent column for every trade on the panel.
• Chart symbol only or every symbol of the account, with any magic, one magic number or manual trades only.
• Not a grid, no martingale, no averaging, no DLLs, no extra files.
QUICK START
Attach it to any chart, for example EURUSD H1, and make sure Algo Trading is on. Keep the defaults: a trade is watched once its peak reaches 150 points, step 1 closes 50 percent of the volume when 35 percent of the peak has been given back, step 2 closes the rest at 60 percent, a three-second confirmation and peak memory on. Look at the PEAK, NOW and BACK columns of the panel: they show at every moment how much of each trade's best profit is still on the table.
Why the peak matters more than the entry
Every trader knows the feeling. A trade runs nicely into profit, you look away for an hour, and when you come back the profit has melted and the trade is at break-even or worse. A normal stop-loss does not help here because it is measured from the entry, and a fixed trailing stop does not care whether the trade made twenty points or four hundred. What really matters is how much of the best result you are giving back. Peak Gain Giveback Guard measures exactly that: a trade that peaked at 400 points and now shows 260 has given back 35 percent, no matter where it was opened.
What is new and different here
Two-step giveback exit. Most protection tools are all or nothing: one level, and the whole trade is gone. Here the first step only banks a part, so a normal pullback inside a trend leaves you with a running position, while a real reversal is caught by the second step. You lock real money early and still keep a seat for the continuation.
Percent of the trade's own peak. The distance grows with the trade. A small winner is protected tightly, a large winner is given more room in points, and the rule stays the same for every symbol and timeframe.
Peak memory. Peaks and completed steps are stored in terminal global variables, keyed by account and ticket. Restart MetaTrader, change the chart or reload the utility and it continues exactly where it stopped, instead of starting again from the current price and forgetting a peak that happened while you were offline.
Giveback meter. A progress bar shows how close the worst trade is to the final step, with an amber marker at step 1, and every row of the table shows its own BACK percent and its state: WAIT, WATCH or STEP 1.
How one trade is handled
1. Waiting. A new position is listed as WAIT until its open profit reaches the watch threshold, 150 points by default. Small trades in the noise are never touched.
2. Watching. From that moment the best profit is recorded as the peak and the state turns to WATCH. Each new high in profit raises the peak; the peak never moves down.
3. Giveback. On every tick and every second the utility compares the current profit with the peak and calculates the percent given back.
4. Confirmation. When the giveback reaches a step, it must stay there for the confirmation seconds before anything is sent, so a single spike does not close your trade.
5. Step 1. The chosen share of the volume is closed, rounded down to the broker's lot step. If the part would be smaller than the minimum lot, the trade is kept whole and handed to step 2; if the remainder would be too small, the whole position is closed.
6. Step 2. If the giveback grows to the second percent, or profit drops below the safety floor after step 1, the rest of the position is closed.
7. Journal and panel. Every exit is written to the Experts journal with ticket, symbol, lots and reason, counted in TODAY and shown as LAST EXIT.
The panel
The panel sits in the top-left corner of the chart and leaves the right side and the price scale free. The header shows the product name, the version, the scope and a status pill: WAITING, GUARDING, GIVING BACK or PAUSED. The GIVEBACK METER bar fills from left to right as the worst watched trade gives back profit, green while small, amber when it approaches step 1, red at a step. The PROFIT GUARD block lists the watch threshold, both steps, the safety floor, the positions in scope with lots and net result, how many are watched and the worst giveback, today's step 1 and step 2 exits with the banked amount, the memory mode and the last exit. The IN-SCOPE POSITIONS table shows side, lots, peak, current profit, back percent and state. A coloured banner sums up the situation in one line. Three buttons switch ARMED / PAUSED, TWO STEPS / PARTIAL ONLY and RESET PEAKS (press twice within six seconds to confirm). The panel can be moved with MOVE and minimised, it measures its own text and shrinks to fit small screens, and in a non-visual backtest nothing is drawn, so tests run at full speed.
Safety in your hands
It only touches what you put in scope: the chart symbol or all symbols, filtered by magic. Trades outside the filter are never read for exits.
It only ever closes volume of a winning trade that has already been watched. It never opens a position on a live or demo account, never adds volume, never changes your stop-loss or take-profit.
PAUSED stops every exit at once while the peaks keep being recorded. PARTIAL ONLY keeps the rest of the trade running after step 1 and leaves the final exit to you or to your own stop.
A spread filter can hold exits while the spread is abnormally wide.
In the Strategy Tester only, an optional small demo position is opened once a day so the steps can be watched; switch it off when you test it together with your own EA.
Every setting explained
Peak - when a trade is watched
Watch threshold (InpMinPeakPoints) - a trade is watched only after its open profit has reached this many points (150). Below it, the trade is left alone.
Money mode (InpCountCosts) - off: peak and giveback are measured in points of price. On: they are measured in account money including swap, and the threshold is converted to money for each trade's volume.
Steps - how much giveback triggers an exit
Step 1 giveback (InpStep1Percent) - percent of the peak that may be given back before step 1 fires (35).
Step 1 close share (InpStep1ClosePct) - percent of the position volume closed at step 1 (50). 100 closes the whole trade at step 1.
Step 2 giveback (InpStep2Percent) - percent of the peak at which the rest is closed (60). It must be above step 1; 0 switches step 2 off.
Safety floor (InpKeepPoints) - after step 1, the rest is closed if profit falls below this many points (20), so the remainder cannot turn into a loss. 0 switches it off; it is not used in money mode.
Filter - which trades are in scope
Symbol scope (InpSymbolScope) - the chart symbol only, or every symbol of the account from one chart.
Magic filter (InpMagicFilter) - any magic (manual and EA trades), only the magic number below, or manual trades only.
Magic number (InpMagic) - the magic used by the "only the magic number" filter.
Timing
Confirmation seconds (InpConfirmSec) - the giveback must stay at a step for this many seconds before an exit is sent (3). 0 acts at once.
Max spread (InpMaxSpread) - exits wait while the spread is above this many points; 0 never waits.
Peak memory (InpRememberPeaks) - keeps peaks and steps in terminal global variables after a restart (on). Not used in the Strategy Tester.
Alerts
Pop-up alert (InpAlertPopup) - terminal alert window for every exit (on).
Push notification (InpAlertPush) - message to the MetaTrader app on your phone (off; set up notifications in the terminal options first).
Watch alert (InpAlertOnWatch) - also alert when a trade reaches the threshold and starts being watched (off).
Panel
Show the panel (ShowPanel) - on or off.
Panel X / Panel Y (PanelX, PanelY) - distance from the left and top edge in pixels.
Base font size (PanelFontSize) - 9 by default; the panel shrinks further by itself on small charts.
Rows in the table (MaxTableRows) - how many positions are listed (6).
Strategy Tester demo
Demo position (InpTesterDemo) - in the Strategy Tester only, opens one small position per day, alternating buy and sell, when none is in scope, so the steps can be watched. It has no effect on a live or demo account.
How to use it well
Trend and swing traders: raise the watch threshold to 300 points or more on H4, keep step 1 at 35 percent and step 2 at 60 percent; the trade has room to breathe and still keeps most of a big move.
Scalpers: lower the threshold to 50 to 80 points, set step 1 to 25 percent and the confirmation to 1 second.
Gold and indices: use money mode, so the rule follows the result in your account currency instead of points that differ from broker to broker.
EA users: set the magic filter to your EA's magic number and use PARTIAL ONLY if the EA must keep control of its final exit.
Several symbols: set the symbol scope to all symbols and run a single copy on any chart.
Test it in the Strategy Tester
Open the Strategy Tester, choose Peak Gain Giveback Guard, a symbol such as EURUSD, H1, "Every tick based on real ticks" or "1 minute OHLC", and switch on visual mode with the tester demo on. You will see a small trade open, the state change from WAIT to WATCH when the threshold is reached, the PEAK column rise with the price and the BACK column grow when the market turns, followed by step 1 and step 2 in the journal. Try other percentages; it costs nothing and shows you how much profit your own symbol tends to hand back.
Your honest review helps
If the utility saved a profit for you, or if you see something that could work better, please leave an honest review on the product page. Every review is read and helps shape the next version for everyone.
Not a grid, no martingale, no averaging. Trading carries risk; a giveback exit is a market close and can be filled at a different price in fast markets or after a gap.
