Shift All Stops By N Pips
Sometimes the right adjustment is not a rule but a nudge. News in an hour, so ten pips of extra breathing room across the book. A move has run well, so twenty pips tighter everywhere to keep more of it. Doing that by hand across a dozen positions is slow, and doing it with a naive script is worse, because "move the stop up by ten pips" is the correct instruction for a buy and exactly the wrong one for a sell. This script takes one signed number and resolves it per position. Positive shifts every stop towards the market - up for a buy, down for a sell - which tightens the risk on both sides. Negative shifts every stop away, widening both sides. One number, one meaning, whatever the book looks like. The second rule is what the script refuses to do: it never creates a stop. A position without a stop loss is skipped and counted, not given one. "Shift the stop" on a naked position is a different instruction from the one the user typed, and a tool that quietly upgrades one instruction into another is how positions end up with stops nobody chose. If you need to fill in missing protection, that is a separate script with a separate validation story. Every shifted level is validated before it is sent. A tightened stop can land inside the broker's minimum stop distance - measured against the correct side of the market, the Bid for a buy and the Ask for a sell - and a position already sitting inside the freeze level cannot be modified at all. Both cases are reported per ticket as skips with the reason and the numbers, never counted as successes and never hammered against the server as error 130 retries. A widened stop on a cheap symbol is also checked against crossing zero, which the server would silently read as "remove the stop". Pips are converted per symbol, so a 3 or 5 digit quote gets its ten points per pip and a 2 or 4 digit one does not. Take profits are passed through untouched: this script moves stops and nothing else. Notes and limitations - The shift is relative to where each stop is now, not to the market. Two positions on the same symbol with different stops keep their spacing; the whole pattern slides by the same amount. - Tightening can fail on positions whose stop is already close to the market. Those are skipped with the candidate price and the market price printed, and the honest fix is a smaller shift, not a retry loop. - Widening a stop increases risk. The script does not have an opinion about whether you should, but the sign convention is printed in the alert so a fat-fingered minus is visible immediately. - The same pip shift is applied to every symbol in the run. Ten pips on EURUSD and ten pips on gold are different fractions of daily range. Use the symbol filter when that matters. - Positions with no stop are never given one. That is the contract, not an omission. - If a trailing EA owns the position, it will move the stop again on the next tick. The script does not fight it.
Script · MT4 · v1.0 · Free
About Shift All Stops By N Pips
Shift All Stops By N Pips is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Shift pips, Current symbol only and Magic filter. MQL source code included.
Files in the download: ShiftAllStops.ex4, ShiftAllStops.mq4, ShiftAllStops.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Shift pips | 0.0 | Pips to shift: positive tightens, negative widens |
| Current symbol only | false | Restrict to this chart's symbol |
| Magic filter | -1 | Only this magic (-1 means every magic) |
| Max retries | 5 | Attempts per position before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: News Trading · Alerts · MT4 Script · MQL4 Source Code