Order Block Respect Rate Study
"Order block" gets used loosely across trading content, usually without a precise, testable definition. This script uses one fixed rule: an impulsive move is a run of InpImpulseBars consecutive bars whose net displacement is at least InpImpulseMultiplier times the average single-bar range of the InpAvgRangePeriod bars immediately before it. The order block is the nearest candle of the OPPOSITE colour found by scanning backward from the impulse's start, up to InpBlockSearchBars bars - the last down candle before an impulsive up move, or the last up candle before an impulsive down move. Its own high/low range is the block's zone. Impulsiveness is measured against the instrument's OWN recent volatility, never a fixed pip count, so the same inputs behave sensibly on a quiet pair and on a fast-moving index without retuning per symbol. The study then scans forward from the impulse for the FIRST bar whose range overlaps the block zone at all - a wick reaching back in counts as a return visit, since that is the market physically revisiting the zone. A fixed number of bars after that visit, the close is checked: still on the impulse side of the block by a threshold (respected), or closed through the far side by that threshold (failed). Results are reported separately for bullish and bearish blocks, with the sample size that was actually revisited shown alongside the respect percentage. Notes and limitations - A block with no qualifying opposite-colour candle within InpBlockSearchBars is skipped rather than forced onto a same-colour bar. - Blocks never revisited within InpReturnScanBars bars are excluded from the respect percentage but are still written to the CSV as "unvisited" if InpSaveCsv is on. - This is a descriptive study, not a trading signal, and not the only possible order-block definition - it is one concrete, reproducible rule chosen so results can be checked and reproduced, not the industry's only interpretation of the term. - It does not account for spread or slippage, and small revisited-sample sizes should be treated with appropriate scepticism.
Script · MT4 · v1.0 · Free
About Order Block Respect Rate Study
Order Block Respect Rate Study is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 12 settings, such as Symbol, Timeframe and Max bars. MQL source code included.
Files in the download: OrderBlockRespectStudy.mq4, OrderBlockRespectStudy.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to study, blank = this chart's symbol | |
| Timeframe | PERIOD_H1 | Timeframe to study |
| Max bars | 6000 | Most recent bars to include |
| Impulse bars | 3 | Bars spanning one impulsive move |
| Impulse multiplier | 2.5 | Net displacement required, as a multiple of the average single-bar range |
| Avg range period | 20 | Bars used to compute the average single-bar range baseline |
| Block search bars | 5 | Bars searched backward from the impulse for the opposite-colour candle |
| Return scan bars | 500 | Bars forward searched for the first return visit to the block |
| Reaction bars | 5 | Bars after the return visit checked for the outcome |
| Fail threshold pips | 5.0 | Close distance past the block's far side needed to call it "failed" |
| Save csv | true | Write every order block event to a CSV file |
| Delimiter | DelimiterComma | CSV column separator |
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: Smart Money (SMC / ICT) · Alerts · MT4 Script · MQL4 Source Code