Last "P4L Clock.mq4" update: Feb 23, 2010, posted new v2_7
Last "P4L CandleTime.mq4" update: Nov 13, 2009, posted new v1_2
Hi all,
I have used CandleTime.mq4 (aka b-Clock.mq4) for a long time, and it had some quirks in the display of single digits (e.g. ":9" instead of ":09"), and sometimes the number of seconds remaining went negative, which I thought was strange and a bit hard to notice the "-" sign.
I cleaned up the code and added some user variables to control color, and/or display of the time by the bar, and/or display of a comment. The by-the-bar text displays single-digit seconds just fine. (":09")
FYI, when the seconds remaining is a negative number, the old bar is over but the new bar is yet to be formed, or in a sense it's overdue. In such cases I now display a "WAIT4BAR:-MM:SS" text so it is clearly distinct from the normal display. (FYI, when markets are slow a lot of M1 and even M5 (and higher) bars never form at all, so the "WAIT4BAR" condition can persist for quite a long while).
The above program I have called
"P4L CandleTime.mq4". You can rename it if you like.
I also decided to modify another time related program, Clock_v1_3.mq4, aka Clock.mq4, that had some similar display issues. That tool displays an array of market names and hours in one corner of your chart. I made some significant enhancements to the indicator which I call
"P4L Clock.mq4" :
* Different highlight color(s) used for Market Open hours (Assuming 8AM - 5PM local market hours)
* Added seconds display, and used method such that single digits look better (":09" not ":9")
* Added "Broker_Time_Is_Gold_Standard" to adjust (by a few seconds or minutes) the market hours, because as if often the case, the local computer clock may be off by a small amount.
* Two extern variables to control display of seconds: bool Display_Time_With_Seconds, int Display_Bar_With_Seconds.
* When Display_Bar_With_Seconds=2 (Auto mode), seconds display when < 2min, OR, if Display_Time_With_Seconds=True.
* "Bar:" changed to "Bar Left:" (remaining time!). Also, it will say "wait4bar" (rather than to display a negative number as would have occurred) during periods of low activity until a new bar is formed.
* "Suppress_Bar_HH_Below_H1" displays only [MM:SS] for H1 and below since HH in [HH:MM:SS] is always "00"
* Adjusted pixel distance between labels depending on options.
* "Bar Left:" time does not display above D1 charts. A future enhancement (not planned) could report DD_HH:MM[:SS]
* Added Show_DIBS_London clock with user-setable start/stop hour relative to London (6AM and 7PM at present). (The DIBS method is discussed over in thread
http://www.forexfactory.com/showthread.php?t=86766 )
(Further enhancements & features are described in the
"Update" section below).
FYI, I found a modification of Clock_v1_3.mq4 called Clock_v1_4.mq4 but which is actually a script. (I posted it elsewhere -- and can't delete it now -- a copy I called Clock_v1_4_script.mq4 ). I posted it without first fully testing it. I had problems using that script. After a bar completed, the bar time wasn't working for me. ('Time[0]' was frozen because it was in an infinite loop with 'Sleep(1)' ). I also couldn't change timeframes without stopping the script and then re-adding it. Maybe I was doing something wrong, but it didn't work well for me.
My version updates on a by-tick basis (but not more than once-per-second). It should be relatively CPU friendly compared to an infinite loop (??). Please NOTE:
The clocks do not update unless new ticks come in. Also note that
on weekends, the broker clock is frozen and even with simulated ticks you will
not see updates! You could try "
Weekend_Test_Mode=true", or better... wait for the market to open.
Installation:
// Copy this file to: C:/Program Files/--your-MT4-directory-here---/experts/indicators/
// Review the "extern" variable settings below. Change as desired, then restart MT4 or do "Compile" in MetaEditor.
//
// Open a chart and add this indicator. Assuming you compiled with the "extern" defaults you prefer,
// you shouldn't need to change any of the defaults, *except* one: (FOR "P4L Clock.mq4" ONLY!)
// This Version requires "
Allow DLL Imports" to be set under the Common Tab when you add this to a chart!
// FYI, the DLLs retrieve the local CPU clock time and timezone info as well as world timezone info.
// A word of caution: You can see my entire source code and what the DLL's do which should be harmless.
// Personally, I *never* enable DLL's on any binary .EX4 file because I don't trust what the program might do.
// For all I know, it could be sending out very private information about me or my account!
//
// NOTE! The world timezone times are only as accurate as your LOCAL CPU CLOCK or, if variable
// Broker_MMSS_Is_Gold_Standard=True, your Broker's clock! At least verify your own clock and set it accurately!
// NOTE! Your Broker time is independent of your local CPU clock and, though unlikely, may change at any time.
(Thanks go to the previous authors for their ideas and implementation which I have further enhanced.)
Please report any issues/problems...
Enjoy!
Pips4life (Kent)
UPDATES:
2008-09-27: New "P4L Clock.mq4" v2_1
"P4L Clock.mq4" version v2_1
addresses all timezone/ST/DST issues. Also adds Sydney TZ. Given reports of problems with the old DST/timezone code, I rewrote that section entirely. TimeZone and ST/DST changeovers should display the correct times regardless of your own timezone and ST/DST change dates. However, plan on revisiting this post early in 2009 (and each year) for an annual update with new ST/DST crossover dates!
(Correction: no annual update is required!).
2008-09-28: New "P4L Clock.mq4" v2_2
Turns out version v2_1 will NOT require annual updates! The timezone info was not limited to 2008 after all. Updates will only be required if ST/DST changeover dates are changed legislatively (such as Tokyo adopting DST, or US/London/Sydney changing their dates). This version has mostly cosmetic changes to remove the reference to "annual" updates. My apologies for the confusion.
2008-09-28: New "P4L Clock.mq4" v2_3 (
Downloaded 1074 times before next version update).
(Note: Covers all issues and enhancements requested through Post #12)
Added Auckland, Moscow, Berlin, Seattle for Jodie(jhp2025). Default topOffsetPixels is now 10.
2008-10-02: New "P4L CandleTime.mq4" v1_1 (
Downloaded 974 times before next version update!)
For H4 and above, display "#hours:MM:SS" bar-remaining time. However, for W1 and MN, the bar remaining time
may not be accurate (depending on your broker weekend closing time) since the Period() function is not precise, and some weekend time
may be included in "remaining" time.
2009-11-13: New "P4L CandleTime.mq4" v1_2
For Weekly and Monthly charts, the number of remaining hours might be excessive (well over 24 hours), so a new format is used: D_HH:MM:SS
The program was also updated to be compatible with timeshifted charts as created by the new "P4L PeriodCon.mq4" indicator. (See
http://www.forexfactory.com/showthread.php?t=206301 for
"Improved multi-timeframe/offset/chart period converter, P4L PeriodCon.mq4"
2009-11-29: New "P4L Clock.mq4" v2_4 (Downloaded 105 times before next version update!)
Changes: New colors plus user control over font name/size, vert. & horiz. offsets and spacing. Reworked auto-spacing of labels based on AM/PM vs. 24 hour, and display of seconds (or not) and ShowBarTime (or not). Added timezones for:
China, Jakarta, India, Israel, Helsinki, Brazil, Mexico, Central and
Mountain; renamed "Seattle" to "Pacific". Label order is consistent for any LabelCorner but can also be reversed. Can be drawn in a chart sub-window. New "OverrideShowALL" to see every timezone. New defaults for zones and display-style but user can change as desired. AM/PM is off. Seconds are displayed to better allow precise calibration of local CPU Clock vs. Broker time (Very helpful for news events).
2010-01-14: New "P4L Clock.mq4" v2_5 (Downloaded 26 times before next version update!)
Changes: New
"Background_Under_Labels" feature draws a rectangle (actually several) under the labels to make them more readable. The rectangle COVERS price bars and other lines/objects (so long as your F8 "Chart on foreground" variable is un-checked, and if other objects have their Background=true. (Traderathome suggested the rather clever use of OBJ_LABEL with font Webdings, key "g", and large fontsize to create the background rectangle). (See GBPJPY H1 picture below which also shows every market zone supported. This shows bottom-left corner, but any corner can be used for the labels).
2010-01-21: New "P4L Clock.mq4" v2_6 (Downloaded 96 times before next version update!)
Changes:
* New
"ShowPipSpread" (Ask-Bid) in pips (including automatic 1/10th pips for extra-digit-brokers).
* New
"ShowBidPrice" where color indicates last tick was higher/lower.
* New
"ShowVolume". Color indicates higher/lower vs. the last bar. Also, the label changes to
"*HiVol*" if the volume is >= the-12th-highest-of-last-120-bars.
* Flag LowSpread by setting
"LowSpreadHighlightThreshold" to >0
* New popup Alerts (once-per-bar):
DoHighVolumeAlerts &
DoLowSpreadAlerts
* New arrows using
DoLowSpreadArrows to mark LowSpread events on the chart. (Because they can't be recreated, these arrows persist unless you remove them by changing
"Delete_Old_SpreadArrows" to true.
* An Alert ERROR now occurs if the user forgets to enable DLLs.
* Regular MarketOpenHours (8A-5P) (and those for Sydney, 7A-4P) can now be customized with external variables if desired.
2010-02-23: New "P4L Clock.mq4" v2_7
Changes:
* Added option for
Dubai timezone
* New "
ShowRange" to show current bar High-Low (in pips)
* New "
ShowPips2open" to display current currentBarPrice-Open in +/- pips
* New "
ShowAvgPeriodRange" to display APR (or A#R). The period, lookback and display are controled with
APR_Period,
APR_Bars and
APR_LabelShowMinutes
* New "
ShowAvgDailyRange". Lookback controlled with
ADR_Bars
* Renamed old "Background_Name_Pixels" to "
Background_AddWidth_Pixels"
* Fixed a few
bugs with v2_6
* KNOWN issue with ADR/APR: When calculations are based on a different chart timeframe, the calculations are only correct if your history data is current for the other timeframe (i.e. ADR will be accurate if your Daily history data is current). Best way to be sure is to have a Daily chart open in addition to the chart you attach this indicator to.
P.S. New screenshots contain a few useful notes. Several new market zones and bar info may not be shown in the older screenshots.
-----------------------------------------------
FYI, see also:
Collection of programs by pips4life
-----------------------------------------------