The bid-ask spread is the ask price minus the bid price. The ask is where you can buy and the bid is where you can sell, so a buy opens at the ask and closes at the bid and every new position starts one spread behind. MetaTrader 5 (MT5) shows the spread in points: a five-digit EURUSD quote of 1.10000 bid and 1.10012 ask has a 12-point spread, which is 1.2 pips.
Part of the trading mechanics library, this guide shows how to measure the spread, why it widens, why a stop can trigger before the chart reaches it, and what PineConnector's spread= filter checks.

Bid, ask and spread at a glance
MetaQuotes states the basic rule: "Generally, a security is bought at the Ask price and sold at the Bid price."[1] The terms below use MT5's names.[2][3]
- Bid: the quoted selling price. The forex examples use Bid for market sells, long closes and a long’s stop trigger. Exchange-mode trigger rules can differ.[1]
- Ask: the quoted buying price. The forex examples use Ask for market buys, short closes and a short’s stop trigger. Exchange-mode trigger rules can differ.[1]
- Spread: ask − bid, a price distance. MT5 shows it in Market Watch, and in points in the symbol Specification.
- Mid price: (ask + bid) ÷ 2. MT5's Cost column measures against it, and TradingView's Help Center says its chart data is built there.
- Floating (variable) spread: a spread that changes with the quotes. The Specification marks it "floating".
- Fixed spread: a spread value the broker sets, shown without the floating mark. The broker's account terms apply.
-
PineConnector pip: 10 quoting points, the unit of
spread=.
How do you calculate the spread in points and pips?
Spread = ask − bid · Spread in points = (ask − bid) ÷ point · Spread in PineConnector pips = (ask − bid) ÷ (10 × point)
The point is the symbol's quoting step, which MQL5 reports as SYMBOL_POINT. MT5's Specification window gives the spread in points, and SYMBOL_SPREAD returns the same value in MQL5.[2][3] This page uses PineConnector's pip, defined as 10 quoting points.[4] On a five-decimal EURUSD quote one pip is 0.00010; on a three-decimal JPY pair it is 0.010; on a two-decimal gold quote it is 0.10.
Metals, indices and crypto CFDs have no pip fixed by market convention, so the guide to pips compares the definitions in use. To compare spreads across symbols with very different prices, a relative spread helps. TradingView's Help Center uses this form for bonds:[5]
Bid-ask spread % = (ask − bid) ÷ ((ask + bid) ÷ 2) × 100
Worked example: what a 1.2-pip spread costs on EURUSD
Illustrative numbers, not a recommendation or a live quote. Commission, swap and slippage are left out so that only the spread shows.
- Quote: bid 1.10000, ask 1.10012. Spread = 1.10012 − 1.10000 = 0.00012, which is 12 points or 1.2 PineConnector pips. The mid price is 1.10006.
- Relative spread: 0.00012 ÷ 1.10006 × 100 is about 0.011%.
- Open: buy 1.00 lot, 100,000 EUR on a standard contract, at the ask of 1.10012.
- Close at once, quotes unchanged: sell at the bid of 1.10000. Result = (1.10000 − 1.10012) × 100,000 = −12.00 USD. At 10 USD per pip for 1.00 lot, that is the 1.2-pip spread.
- Against the mid: the entry pays 0.6 pip (1.10012 − 1.10006) and the exit pays 0.6 pip (1.10006 − 1.10000).
- To break even: the bid has to rise to 1.10012, 1.2 pips, before the position shows zero.
- Widened exit: with the mid still at 1.10006 but a 3.0-pip spread at exit, the bid is 1.10006 − 0.00015 = 1.09991. Result = (1.09991 − 1.10012) × 100,000 = −21.00 USD: 0.6 pip at entry plus 1.5 pips at exit.
Pip value depends on the contract size, which is broker-specific; read it in the symbol Specification.[2] The full cost of a trade adds commission, swap and slippage to this spread.
Why does a buy open at the ask and close at the bid?
A buy takes the lowest price a seller currently accepts, the ask, and a sell takes the highest price a buyer currently pays, the bid. Closing reverses the side. TradingView's Help Center puts it the same way: a long position "closes at the Bid Price and the Short one at the Ask Price".[6] The CFTC reminds retail forex customers that a dealer makes money when they trade more often, lose money, or pay fees, spreads or commissions.[7]
For the forex/OTC examples, buy pending orders trigger on Ask and sell pending orders on Bid; a long’s SL/TP uses Bid and a short’s uses Ask. Exchange Stocks, Exchange Futures and Futures Forts follow exchange trigger rules, usually Last. Trigger price is separate from the resulting buy/sell execution quote.[1] The order types guide covers the types and their conditions.

Why did my stop trigger before the chart reached it?
The chart you watch and the quote your stop watches are often different prices. MT5 says: "Bars in the platform are formed based on Bid prices (or Last prices if the depth of market is available for the instrument)." The ask is not drawn unless you enable "Show Ask price line".[8] A short's stop loss watches the ask, so it can trigger while the bid chart peaks one full spread below the stop.
TradingView's Help Center says orders execute at the ask and bid "while the chart data is built at the middle price of the market's Buy and Sell".[6] A separate article states that FOREX.com charts "are based on Mid-price".[9] TradingView's forex symbols also come from different providers: ICE symbols are composites of dozens of contributors, while others come from individual brokers.[10] PineConnector's FAQ notes that TradingView and MetaTrader can use different data feeds, bid/ask quotes, spreads and timestamps.[11]
- Short position, stop at 1.10200: the stop triggers when the ask reaches 1.10200. With a 5.0-pip spread at that moment, the bid is 1.10150 and the mid is 1.10175. A bid chart can peak 5.0 pips below the stop, and a mid-based chart 2.5 pips below it.
- Long position, stop at 1.09800: the stop triggers when the bid reaches 1.09800. The bid chart touches the line, but with a 5.0-pip spread the mid is 1.09825, so a mid-based chart's low can stay 2.5 pips above the stop.
- Pending stop entries in this forex example: a pending sell stop triggers when the bid falls to its price, and a buy stop when the ask rises to its price.[1]
To see both quotes, enable "Show Ask price line" in MT5's chart settings.[8] As of 25 September 2026, TradingView's Help Center points to Settings, then Scales, then "Bid and Ask Labels" to show them on the price scale.[6]

A TradingView backtest does not see any of this by default. The broker emulator fills a strategy's orders "using only the available chart data by default".[12] As of 25 September 2026, Pine Script v6's bid and ask variables are available only on the "1T" timeframe and return na on others.[13] The Strategy properties page says its slippage setting, in ticks, "can be used to account for the spread".[14] The guide to why TradingView prices differ from your broker covers feed differences beyond the spread.
What is spread widening, and when does it happen?
Spread widening is a temporary increase in the gap between bid and ask. A floating spread can change from one tick to the next. MT5's Specification marks such a spread as floating, and MetaQuotes notes that with real ticks "a spread may change within a minute bar".[2][15] A fixed spread is a value the broker has set; the broker's account terms say when it applies.
- Around major news: IG's trading course says that, because nobody knows a release's outcome in advance, liquidity providers "look to offset some of their risk by widening spreads". It adds that a higher-than-normal spread generally signals high volatility or low liquidity.[16]
- At the daily rollover: one broker's rollover notes say spreads on its FX and metals products "noticeably widen" while banks reconnect. The same notes say volatility generally persists for 30 minutes to an hour afterwards.[17] The swap and rollover guide explains what the rollover is.
- When fewer deals trade: in interdealer data for USD/JPY and EUR/USD, Ito and Hashimoto (2006) found a negative correlation between the number of deals and the width of the spread during business hours.[18] The forex sessions guide covers when each centre is active.
None of these sources gives a spread you should expect at a given time. Record your own broker's spread at the hours your rules act. MT5's History tab can help after the fact: where the server provides it, the Cost column shows a deal's cost relative to the mid-point price, which MetaQuotes calls "the amount which the trader loses on traded spread".[19]
From TradingView alert to MT5 order: where the spread enters
- Alert condition: a rule becomes true on the TradingView chart, which may be mid-based or from another provider's feed. No broker spread is involved yet.
- Alert trigger and webhook: TradingView sends the configured message, which may include chart-price values. Those are separate from the receiving broker’s Bid/Ask quote used by the spread check.[22][4]
-
PineConnector processing: if the message includes
spread=, the spread is taken from the broker's quote when the signal arrives.[4] - EA order request, broker acceptance and deal: the EA sends the request, and if the broker accepts it, a buy generally fills at the ask and a sell at the bid.[1] The filled price can still differ from the requested one; see slippage.
- Position: a broker-side stop loss then watches the bid for a long and the ask for a short. A stop that exists only in the strategy's logic watches whatever that logic reads.
How PineConnector's spread= filter works
PineConnector's spread= parameter sets the maximum entry spread in PineConnector pips, and decimal values are supported. The docs define the check as "Spread = (Ask − Bid) ÷ pip size at arrival", and a spread equal to the limit passes.[4]
Demo test only. Confirm every account sharing the selected License ID is a demo account before creating the alert. These messages request broker trades or closures. Check the exact symbol and permitted volume, and add your configured secret= if required.[21]
Illustrative message, not a recommendation. Paste it into the TradingView alert's Message field, with your License ID in place of LicenseID:
LicenseID,buy,EURUSD,vol_lots=0.01,sl_pips=20,spread=2
This requests a 0.01-lot buy with a 20-pip stop, only if the entry spread is 2.0 PineConnector pips or less. With a bid of 1.10000 and an ask of 1.10020 at arrival, the spread is 0.00020 ÷ 0.00010 = 2.0 pips, so the filter passes. With an ask of 1.10038, the spread is 3.8 pips and the alert is filtered out at that arrival.[4]
- One check at arrival. The docs say a later narrowing "does not change the spread recorded for an earlier alert".[4]
- Not a confirmed order. Passing this filter leaves every other EA check and broker rule in place.[4]
- Entries only in the converter. PineConnector's Pine Script converter applies its entry filters "to entry requests, not generated close requests".[20]
- Not a cost cap. The filter checks the entry spread. It does not limit the exit spread, slippage, commission or swap.
PineConnector's stop examples use a single market reference and state that the bid/ask spread is omitted.[4] Which quote the EA measures sl_pips= from is not documented; test on demo. If a buy's 20-pip stop were measured from an ask fill with a 1.2-pip spread, the bid would have 18.8 pips of room before the stop.
Common spread mistakes
- Reading a short's stop off the bid chart. The stop watches the ask, which MT5 does not draw by default.[8]
- Assuming TradingView and MT5 show the same price. A mid-based chart sits half a spread from both quotes, and the feeds themselves can differ.[6][11]
- Testing with a quiet-hours spread only. A floating spread measured in liquid hours says little about the rollover or a news release.[17]
- Counting the spread twice. If a backtest's slippage setting already carries the spread, do not deduct it again.[14]
-
Mixing pip conventions.
spread=2means 20 points on every symbol. On a two-decimal gold quote that is 0.20, not 0.0002.[4] - Forgetting that a stop starts one spread closer. A long's stop loss must sit below the current bid and a short's above the current ask, so a stop measured from the fill has one spread less room.[1] Brokers also enforce a minimum distance, covered in stops level and freeze level.
Automation does not remove the spread. It executes the rules you wrote at the broker's quotes, including when spreads are wide.
Frequently asked questions
What is spread in forex?
The spread in forex is the difference between a currency pair's ask price, where you buy, and its bid price, where you sell. On a five-digit EURUSD quote of 1.10000 bid and 1.10012 ask, the spread is 0.00012: 12 points, or 1.2 pips. A new position starts one spread behind, because a buy opens at the ask and closes at the bid.
What is spread widening?
Spread widening is a temporary increase in the gap between the bid and ask prices. Broker and academic sources link wider spreads to lower liquidity and higher uncertainty, such as the daily rollover, quiet trading hours and major news releases. A wider spread raises the cost of entering and exiting, and can move a stop's trigger quote closer to its level.
Why did my stop loss trigger when the chart never reached it?
In the forex example, a short’s stop triggers on Ask while the MT5 chart shows Bid, so the chart can remain below the stop. A mid-based TradingView feed can differ again. Exchange Stocks, Exchange Futures and Futures Forts follow exchange trigger rules, usually Last. Check the symbol’s calculation mode and trigger rules before comparing its chart and stop.
What is the difference between a fixed and a variable spread?
A variable, or floating, spread changes with market quotes and can widen when liquidity is thin. A fixed spread is a value the broker sets under its account terms. In MetaTrader 5 the symbol Specification shows the spread in points and marks a floating spread as floating; MQL5 exposes this as SYMBOL_SPREAD_FLOAT.
How do you calculate the spread in pips?
Subtract the bid from the ask and divide by the pip size. With PineConnector's convention of one pip equal to 10 quoting points, a five-decimal EURUSD quote has a pip of 0.00010. A bid of 1.10000 and an ask of 1.10020 give 0.00020 ÷ 0.00010 = 2.0 pips. MT5 shows the same spread as 20 points.
Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account.
Related reading
- Trading mechanics library: orders, lots, margin and costs
- The full cost of a trade: spread, commission, swap and slippage
- Order types: market, limit, stop and stop-limit in MT5
- Why TradingView prices differ from your broker's
- Pips, points and pip value
Sources
- MetaQuotes – Basic Principles (MetaTrader 5 Help), accessed 25 September 2026.
- MetaQuotes – Market Watch (MetaTrader 5 Help), accessed 25 September 2026.
- MetaQuotes – MQL5 Reference: Symbol Properties, accessed 25 September 2026.
- PineConnector Docs – PineConnector Syntax: PineConnector pip and spread=, accessed 25 September 2026.
- TradingView – Bid ask spread %, accessed 25 September 2026.
- TradingView – Why is the price of the order execution different from the Close price on the chart?, accessed 25 September 2026.
- CFTC – Customer Advisory: Eight Things You Should Know Before Trading Forex, accessed 25 September 2026.
- MetaQuotes – Chart Settings (MetaTrader 5 Help), accessed 25 September 2026.
- TradingView – Why was my order executed/not executed, although the price on the chart reached or didn't reach the order level?, accessed 25 September 2026.
- TradingView – What is the difference between ICE and other forex providers?, accessed 25 September 2026.
- PineConnector Docs – Frequently asked questions: price differences, accessed 25 September 2026.
- TradingView – Pine Script Strategies: broker emulator, accessed 25 September 2026.
- TradingView – Pine Script release notes: February 2025, bid and ask variables, accessed 25 September 2026.
- TradingView – Strategy properties, accessed 25 September 2026.
- MetaQuotes – Real and Generated Ticks (MetaTrader 5 Help), accessed 25 September 2026.
- IG – Understanding forex spreads, accessed 25 September 2026.
- Global Prime – Market Rollover, accessed 25 September 2026.
- NBER – Ito and Hashimoto, Intra-Day Seasonality in Activities of the Foreign Exchange Markets, Working Paper 12413 (2006), accessed 25 September 2026.
- MetaQuotes – Executing Trades: trading history (MetaTrader 5 Help), accessed 25 September 2026.
- PineConnector Docs – Pine Script converter: entry filters, accessed 25 September 2026.
- PineConnector – Test your setup: demo account and License ID scope, accessed 25 September 2026.
- TradingView – How to use a variable value in alert, accessed 25 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.