What is Bar Magnifier backtesting mode
You can obtain more realistic order fills in your strategy backtesting by using the "Bar Magnifier" option. This tool uses intrabar inspection to give you a more granular view of price movement within a bar for more precise order fills.
When enabled, Bar Magnifier mode makes the broker emulator use only OHLC values for historical bars instead of assuming how the price moved.
The intrabar interval used with the Bar Magnifier dynamically adjusts with the chart interval. The following table lists the intrabar intervals used for progressively higher chart intervals.
Here's an example of a strategy that uses a stop order without using the Bar Magnifier option.
//@version=5
strategy("bar_magnifier_demo", overlay = true, use_bar_magnifier = false)
if bar_index == 10381
strategy.entry("Long", strategy.long, stop = 157.0)
strategy.exit("Exit", stop = 156.0)
The broker emulator places a stop order on bar #10,381 and fills an order with a price of 157.0 on the next bar as soon as the stop = 157.0 condition is met. The broker emulator estimates that inside the bar itself, the price goes from "open" to "low," then to "high" (triggering the entry), then to "close." After a few bars (11 days for the current timeframe), the condition for exiting the position with the stop price = 156.0 is triggered.

When the Bar magnifier is enabled (parameter use_bar_magnifier = true), exit and entry prices are unchanged. However, the exit from the position occurs inside the same bar in which the entry happened.
//@version=5
strategy("bar_magnifier_demo", overlay = true, use_bar_magnifier = true)
if bar_index == 10381
strategy.entry("Long", strategy.long, stop = 157.0)
strategy.exit("Exit", stop = 156.0)

If we check the lower chart interval for the same symbol (a 60-minute chart, according to the intrabar interval table) and find the time range corresponding to bar 10,382, we can see that on the hourly interval, after reaching 157.0 and triggering the entry, the price goes down below 156.0, satisfying the stop = 156.0 condition.

With Bar Magnifier on, the broker emulator gets access to price changes from lower intervals during backtesting, making its behavior more similar to what would happen during forward testing the strategy for the same time period.
To switch the Bar magnifier option, toggle the corresponding input in strategy's "Settings/Properties" window.

! Note: The strategy can't request more than 200,000 bars from the lower timeframe.
For symbols with a lot of historical data (where Num of Bars on the Chart × Num of Lower Timeframe Bars per Chart Bar > 200,000), the first trades on the chart might not be affected by the bar magnifier.
The number of bars, starting from the end of the chart, that can be affected by the Bar Magnifier can be roughly calculated using the following formula.
last_bar_index - (200000 / Num of Lower Timeframe Bars per Chart Bar)
The resulting value will be a rough approximation, because the number of lower timeframe bars can differ from one bar to another.
Also read: