Slippage Protection

The pre-fill spread gate (marketprice, maxspread_pips, maxspread_pct) on MT5 and cTrader, and the post-fill extreme slippage disclosure for close commands.

Last updated: 2026-10-08

PineHook protects your entries in two ways and treats closes differently. Before an entry is sent, a spread gate checks the live market and skips the entry if the spread, or the move away from your strategy's price, is larger than you allow. A close is never held back by price, so it always runs, and if it fills unusually far from the expected price, Signal Logs tells you afterward.

The spread gate#

Three parameters control the gate:

ParameterWhat it doesAccepted values
maxspread_pipsThe largest spread or price move allowed, in pips0 to 100,000
maxspread_pctThe same limit as a percentage of price, so 0.05 means 0.05%0 to 100
marketpriceThe price your strategy saw when the alert fired0 to 1,000,000,000
LICENSE,buy,EURUSD,size_lots=0.1,sl_pips=30,maxspread_pips=3,marketprice={{close}}

The gate checks every entry, including pending orders, the opening step of commands that close and then open, and the opening part of setposition. Closes, cancels and trade management commands never go through it.

With or without marketprice#

Without marketprice, the gate measures the broker's spread, the gap between the ask and the bid. This catches a wide market, such as one just after a news release, but it can't tell whether your alert is late.

With marketprice, the gate measures how far the price you would get has moved from the price your strategy saw. A buy compares the ask and a sell compares the bid, so a late alert is skipped even while the spread is tight. Because only that one price is compared, a wide spread on its own doesn't trigger it.

What's happeningWithout marketpriceWith marketprice
Tight spread, price close to the alertSentSent
The alert is late and price has moved, but the spread is tightSentSkipped
Wide spread, but the price you'd get is still close to the alertSkippedSent
Wide spread and price has movedSkippedSkipped

marketprice does nothing on its own, since it only gives the gate a reference to measure against a pips or percent limit. On a pending order, the gate checks the live ask or bid when the alert arrives, not the order's entry price.

Limits and defaults#

When you set both a pips and a percent limit, the entry must pass both, and the pips limit is checked first. You can also set default limits so you don't have to repeat them in every alert, and those apply whenever an alert leaves a limit out or sets it to 0. A 0 in the alert therefore means "use my default", not "turn the check off", and the check is only off when both the alert and the default are 0.

The defaults are Max Spread (Pips) and Max Spread (%) in your trading settings, set for all licenses or overridden for one. cTrader always uses them, while MT5 uses them only when the EA's Settings Source is Dashboard. With the default MetaTrader source, the EA uses its own Max Spread inputs instead, as described in Trading settings.

A pip is the symbol's pip size as the platform reports it. On MT5, that's 10 points for forex symbols with 3 or 5 digits, and otherwise the larger of one tick and one point, so a pip on an index or a future is one tick. On cTrader, it comes from the broker's pip position for the symbol.

When an entry is skipped#

A skipped entry never reaches the broker, and its Signal Logs row shows Failed. On MT5, it also shows an amber Trade rejected pill, and expanding it shows the measured value, the limit and where the limit came from. On cTrader, the row reads Slippage protection rejected the entry followed by a code such as TRADE_SPREAD_PIPS. TradingView still shows the alert as delivered, since the gate runs after PineHook has accepted it.

A command that closes and then opens runs its close first, so if the gate then skips the opening step, the close has already happened and the row says so.

Closes always run#

PineHook never holds back a close because of spread or price movement, so a position isn't left open in a fast market. On MT5, the EA sends closes with a very wide price tolerance of 50,000 points, and market entries with a fixed 10 points. Neither can be changed, and the old slippage= parameter is no longer accepted.

When a close fills more than 100 points from the price PineHook saw when it sent the close, the Signal Logs row gets an amber Extreme volatility badge showing the slippage in pips. Hovering over it shows the pips, the points and the reference price. The close has already finished, so the badge is there for your records and needs no action. On a 5-digit forex pair, 100 points is 10 pips, and when one command closes several positions, the badge shows the largest slip among them.

Good to know#

  • The gate checks the price when the alert runs. An alert that waited in a delay, a queue or a reconnect is checked against the price at that moment.
  • Spread limits are validated even where they don't apply. An out-of-range maxspread_pips on a close alert is still rejected, although valid values do nothing there. modify, trail and breakeven reject these parameters outright.
  • A Trade Copier copies these parameters unchanged. Only sizes and setposition targets are scaled for each account.
  • PineConnector syntax maps spread= to maxspread_pips.

Alert error messages lists the validation messages for these parameters.