Loading…

Prior Day Level Magnet

"Price respects yesterday's high/low/close" is one of the most repeated claims in day trading, and almost never actually measured. This script measures it directly: for every trading day in the loaded history it reads the prior day's high, low and close from the daily timeframe, then scans that day's intraday bars for the first bar whose range touches each level. A fixed number of bars after that touch, it checks whether the close has moved away from the level (a rejection) or through it (a breakthrough). Only the FIRST touch of a level within its own trading day counts. If price grinds across yesterday's high for the first three hours of the session that is one approach, not three - counting every bar that overlaps the level would inflate the sample with repeats of the same episode. A level's counter resets naturally each day because a new prior day high/low/close is computed every day. The three level types are scored and reported separately, because there is no reason to assume yesterday's close behaves like yesterday's high just because both are "prior day levels" - pooling them into one number would hide whichever one is actually different. Notes and limitations - A day with no intraday bars mapped to it (a data gap or a broker holiday) is skipped rather than guessed at. - The first bar of a trading day that already opens beyond a level (an overnight gap through prior day high/low) is scored as touching on that first bar, using the open to infer approach direction. - The outcome is judged from the close InpReactionBars bars later, not the extreme price reached in between - a level briefly broken and then closed back on the near side is scored a rejection. - This is a descriptive study, not a trading signal. It does not account for spread or slippage, and a small sample size undermines the percentages just as it would for any base-rate study.

Script · MT4 · v1.0 · Free

About Prior Day Level Magnet

Prior Day Level Magnet is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Symbol, Timeframe and Max days. MQL source code included.

Files in the download: PriorDayLevelMagnet.mq4, PriorDayLevelMagnet.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to study, blank = this chart's symbol
TimeframePERIOD_M15Intraday timeframe scanned for touches
Max days250Most recent trading days to include
Reaction bars8Bars after the touch checked for the outcome
Reaction threshold pips8.0Move past/away from the level needed to call an outcome
Save csvtrueWrite every touch event to a CSV file
DelimiterDelimiterCommaCSV column separator

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria