Prior Day Week Month Levels with Touch Alerts MT4
- Indicators
-
Kazuma Uezono
MQL5 / MQL4 / Pine Script v6 developer and active trader.
Seller on the MQL5 Market (indicators for MT4/MT5).
Services:
- TradingView Pine Script to MT5/MT4 conversion (bar-by-bar matching, with tester report)
- MT4 to MT5 migration - Version: 1.1
Prior Day Week Month Levels with Touch Alerts MT4 puts yesterday's, last week's and last month's high and low on your MetaTrader 4 chart, drawn the way TradingView users are used to seeing them: thin horizontal lines with a short label and price at the right edge. Optional extras: previous day close and today's open, and an alert when price touches a line.
WHAT YOU SEE
Line | Meaning | Default look
PDH | previous day high | blue #2962FF, solid
PDL | previous day low | blue #2962FF, solid
PWH | previous week high | orange #FF9800, dashed
PWL | previous week low | orange #FF9800, dashed
PMH | previous month high | purple #9C27B0, dash-dot
PML | previous month low | purple #9C27B0, dash-dot
PDC | previous day close | grey, dotted (off)
DO | today's open | cyan, dotted (off)
The current lines run from the start of their period to the latest bar plus 15 bars (Extend, 0-500). Set "Periods to draw" above 1 (max 50) to keep the lines of earlier periods as well.
WHERE THE NUMBERS COME FROM
All values are read from D1 bars: the high, low and close of the last finished day, week or month, and today's open. That is why M15, H1 and H4 show identical levels. This is the same "previous period" value that TradingView scripts get from request.security(..., high[1]). Our test against an independent reference calculation found no differences.
MT4 SETUP NOTES - PLEASE READ
1. Server time. Days, weeks (Monday start) and months follow your MT4 server clock, not your PC clock. If your broker's server day starts at a different time from TradingView's day (a GMT+0 server, or CFDs with their own session hours), the daily and weekly levels will not be the same as on TradingView.
2. Sunday bars. "Sunday bars" input: Auto (added to Monday on symbols without Saturday bars, otherwise its own day), Merge into Monday, Own day, or Ignore.
3. D1 history. Open a D1 chart of the symbol once if the levels do not appear; the indicator keeps trying for up to 60 seconds after loading.
4. Colors are set in the Inputs tab. The lines and labels are chart objects, so the Colors tab is not used.
5. MT4 cuts long object texts, so a very long combined label may be shortened. The tooltip shows the full list.
6. Right after loading (up to about 15 seconds) the name in the indicator list can briefly read "probe#..." while it checks that it sits on a chart. This is normal.
7. MT4 lists the inputs without group headings, in the order shown at the bottom of this page.
LABELS THAT WOULD OVERLAP
When two or more levels are closer than the height of the label text, they share one label: "PDH / PWH 1.27450" if the prices are equal, or "PDC 1.27216 / DO 1.27214" if they are not. Zooming in separates them again.
LONG TIMEFRAMES
On W1 the daily lines are not drawn, and on MN1 neither daily nor weekly lines are drawn, because one bar is longer than those periods. If every chosen line is hidden, a short message says so.
TOUCH ALERTS
Off by default. With "Alert: price touches a level" = true:
- the Bid touching or crossing a shown line of the current period raises an alert;
- each line alerts once per period (today's PDH once today, this week's PWH once this week), and this is remembered after a timeframe change or a restart;
- the first tick after loading or after a new period starts is only used as the starting point;
- text example: "Prev H/L TV GBPUSD H1: price touched PWL 1.26880 (1.26879)";
- pop-up, sound and push (MetaQuotes ID required) can be combined; English or Japanese text.
An alert means price reached a line, nothing more. It is not a trade recommendation, and price may go straight through any of these levels.
iCUSTOM BUFFERS
8 buffers, not drawn: 0 PDH, 1 PDL, 2 PWH, 3 PWL, 4 PMH, 5 PML, 6 PDC, 7 DO, with the values valid at each bar; EMPTY_VALUE if none. Same order as the MT5 edition. Called through iCustom, it draws nothing and sends no alerts.
INPUTS (MT4 ORDER)
Sunday bars = Auto; Periods to draw = 1 (1-50); Extend current lines right = 15 (0-500); Show PDH / PDH color / Show PDL / PDL color / Day lines style / Day lines width (1-5); the same for the week (PWH, PWL) and the month (PMH, PML); Show PDC = false / PDC color / PDC style; Show DO = false / DO color / DO style; Show labels at the right end = true; Label text = Short; Show prices in labels = true; Label font size = 8 (6-20); Alert: price touches a level = false; Alert by pop-up = true; Alert by sound = false; Alert by push notification = false; Language = Auto (terminal language), English or Japanese.
Out-of-range values stop the indicator from loading, with the reason in the Experts log.
ALSO GOOD TO KNOW
- No alerts in the Strategy Tester.
- The alert memory uses terminal global variables named PHLTV_...
- No DLLs, no files, no internet access.
- This is an analysis tool. It does not place trades, and no trading result is promised.
SUPPORT
Help with installation, settings and bug reports via MQL5 messages. I do not answer questions about market direction or specific trades.
The MT5 edition (a separate product) and other tools by the same author are listed on my seller profile.
TradingView is a trademark of TradingView, Inc. This product is not affiliated with, sponsored by or endorsed by TradingView, Inc.
