IMPORTANT UPDATE (May 7, 2017):
Pips4life has very generously updated these functions so that they will work correctly in MT4 builds 600 or later. You can download the new versions of the files, and also read his notes and disclaimers, here. As far as I know, the functions should continue to work exactly as they did before.
____________________________
INSTRUCTIONS
Updated January 7, 2014:
I've added more functions since this post was last updated.
For the complete list of functions, refer to the 'hanover --- function header (np).mqh' file.
Updated August 7, 2013:
I've added maybe 5-6 more functions since this post was last updated.
For the complete list of functions, refer to the 'hanover --- function header (np).mqh' file.
Updated Jan 28, 2013:
1. Added the following functions:
iRegr() — returns &pips, &slope, &stdev of regression curve defined by symbol, period, poly degree, #points, st devs, hist shift
PlotTL (objname, delete, window#, time1, price1, time2, price2, color, width, style, ray, backg, vis); // Plot trendline
PlotBox (objname, delete, window#, time1, price1, time2, price2, color, width, style, backg, vis); // Plot rectangle
PlotArrow (objname, delete, window#, time1, price1, color, size, code, backg, vis); // Plot arrow
PlotVL (objname, delete, window#, time1, color, width, style, backg, vis); // Plot vertical line
PlotHL (objname, delete, window#, price1, color, width, style, backg, vis); // Plot horizontal line
PlotText (objname, delete, window#, time1, price1, text, color, size, font, angle, backg, vis); // Plot text
PlotLabel (objname, delete, window#, corner, hpos, vpos, text, color, size, font, angle, backg, vis); // Plot text label
Updated Jan 3, 2013:
1. Added the following functions:ColorToStr() — converts a MT4 color value to its equivalent string token (e.g. "AliceBlue", "BurlyWood", "Red", "b101g96r44" etc)
Updated Oct 11, 2012:
1. Added the following functions:
DayNumber() — given a MT4 datetime, returns number of days since 1 Jan 1970WeekNumber() — given a MT4 datetime, returns number of weeks since 1 Jan 1970
MonthNumber() — given a MT4 datetime, returns number of months since 1 Jan 1970
Updated Sept 15, 2012:
1. Added StrToColorArray() function.
Updated April 28, 2012:
1. Added MathFactorial() function.
2. Fixed bug in StrToDoubleArray(), StrtoIntegerArray(), StrToStringArray() functions, which were previously not handling null strings correctly.
Updated April 22, 2012:
During my time as a MT4 programmer, I have extended the MQL4 language by adding more than 80 new functions. These perform string, number, date and array manipulations, that IMO should be a basic part of any good programming language. Here is a list, and brief description, of these functions:
AppendIfMissing() — appends a character to a string if it's not already the rightmost character
AppendIfNotNull() — appends a character to a string if the string is not null
BarConvert() — converts a bar# (candle#) to the equivalent bar# on another timeframe
BaseToNumber() — performs multibase arithmetic: converts a non-base 10 number (string) to a base 10 integer
BoolToStr() — converts a boolean value to "true" or "false"
ColorToStr() — converts a MT4 color value to its equivalent string token (e.g. "AliceBlue", "BurlyWood", "Red", "b101g96r44" etc)
DateToStr() — formats a MT4 date/time value to a string, using a very sophisticated format mask
DatesToStr() — performs multiple DateToStr() operations in a single function
DayNumber() — given a MT4 datetime, returns number of days since 1 Jan 1970
DebugDoubleArray() — unloads a set of values from a double array, prefixed by the element number, to a single string
DebugIntegerArray() — unloads a set of values from an int array, prefixed by the element number, to a single string
DebugStringArray() — unloads a set of values from a string array, prefixed by the element number, to a single string
DivZero() — returns 0 instead of 'divide by zero' error, if denominator evaluates to 0
DoubleArrayToStr() — unloads a set of values from a double array to a single string, inserting a specified delimiter between the values
EasterDay() — returns the MT4time value of Easter Sunday for the given year
ExpandCcy() — expands a curency symbol name, e.g. "EJ" to "EURJPY"
ExtractAlpha() — returns alphabetic (or other) characters in a string
ExtractUnique() — returns 1 occurrence only of each char in a string; result may be optionally sorted asc/desc
FileSort() — shell sorts an ASCII text file, rewriting the file with its records in alphanumeric order
GetHash() — calculate and return checksum of a string
GetVisibility() — returns suitable OBJPROP_TIMEFRAMES value from a timeframes string (e.g. "M1,M5,M15")
IntegerArrayToStr() — unloads a set of values from an int array to a single string, inserting a specified delimiter between the values
iRegr() — returns &pips, &slope, &stdev of regr curve defined by pair, tf, poly degree, #points, st devs, hist shift
ListGlobals() — lists all GlobalVariables and their values, to a string
ListOrders() — lists all orders of your chosen stati (open/pending/closed/deleted) to a string
LookupDoubleArray() — looks up a numeric value in a double array, returning the element number (if found)
LookupIntegerArray() — looks up a numeric value in an int array, returning the element number (if found)
LookupStringArray() — looks up a string value in a string array, returning the element number (if found)
MathFactorial() — calculates a factorial n(n-1)(n-2)...1 using a recursive technique
MathFix() — returns the value of N, rounded to D decimal places (fixes precision bug in MQL4 MathRound)
MathInt() — returns the value of N, rounded DOWN to D decimal places (fixes precision bug in MQL4 MathFloor)
MathSign() — returns the sign (-1,0,+1) of a number
MonthNumber() — given a MT4 datetime, returns number of months since 1 Jan 1970
NumberToBase() — performs multibase arithmetic: converts a base 10 integer to a non-base 10 number (string)
NumberToStr() — formats a numeric (int/double) value to a string, using a very sophisticated format mask
NumbersToStr() — performs multiple NumberToStr() operations in a single function
OrderStatus() — given a ticket number, returns the order status (O=open, P=pending, C=closed, D=deleted, U=unknown)
ReadWebPage() — reads a page from a specified URL into a string
ReduceCcy() — reduces a currency symbol name, e.g. "EURJPY" to "EJ"
ReturnDay() — returns the MT4time value of the (e.g.) 3rd Sunday after 14 Feb 2011
ShellsortDoubleArray() — shell sorts an array of double values into ascending or descending sequence
ShellsortIntegerArray() — shell sorts an array of int values into ascending or descending sequence
ShellsortString() — shell sorts the characters in a string into ascending or descending ASCII sequence
ShellsortStringArray() — shell sorts an array of string values into ascending or descending ASCII sequence
StrToBool() — converts a suitable string (T(rue)/t(rue)/F(alse)/f(alse)/1) to a boolean value
StrToChar() — returns the decimal ASCII value of a 1 byte string (inverse of MQL4's CharToStr())
StrToColor() — converts a string (color name, RGB values, etc) to a MQL4 color
StrToColorArray() — loads a color array from a delimiter-separated set of string values (e.g. "Blue,Green,Red"); returns the number of array elements loaded
StrToDate() — converts a number of different string patterns to a MT4 date/time value
StrToDoubleArray() — loads a double array from a delimiter-separated set of string values (e.g. "1,2,3"); returns the number of array elements loaded
StrToIntegerArray() — loads an int array from a delimiter-separated set of string values (e.g. "1,2,3"); returns the number of array elements loaded
StrToNumber() — strips all non-numeric characters from a string, returning a numeric (int/double) value
StrToStr() — left/right/center aligns, or truncates, a string, using a very sophisticated format mask
StrToStringArray() — loads a string array from a delimiter-separated set of string values (e.g. "1,2,3"); returns the number of array elements loaded
StrToTF() — converts a timeframe string to a number (e.g. "M15" to 15)
StringArrayToStr() — unloads a set of values from an string array to a single string, inserting a specified delimiter between the values
StringDecrypt() — unencrypts a string that was previously encrypted using StringEncrypt()
StringEncrypt() — encrypts a string
StringExtract() — extracts the content of string between 2 specified delimiters
StringFindCount() — returns the number of occurrences of a certain substring in a string
StringInsert() — inserts characters into a given position in a string
StringLeft() — returns the leftmost characters, or all but the N rightmost characters, of a string
StringLeftExtract() — extracts N characters from a string, counting from the left
StringLeftPad() — inserts specified padding characters at the beginning of a string
StringLeftTrim() — removes all leading spaces from a string
StringLower() — converts all alphabetic characters in a string to lowercase
StringOverwrite() — overwrites characters in a given position of a string
StringRepeat() — returns a given string, repeated N times
StringReplace() — replaces substring in a string with another substring
StringReverse() — reverses a string, e.g. "ABCDE" becomes "EDCBA"
StringRight() — returns the rightmost characters, or all but the N leftmost characters, of a string
StringRightExtract() — extracts N characters from a string, counting from the right
StringRightPad() — appends specified padding characters to the end of a string
StringRightTrim() — removes all trailing spaces from a string
StringTranslate() — translates characters in a string, given a full translation table
StringTrim() — removes all (leading, trailing and embedded) spaces from a string
StringUpper() — converts all alphabetic characters in a string to uppercase
StrsToStr() — performs multiple StrToStr() operations in a single function
TFToStr() — converts a number to a timeframe string (e.g. 1440 to "D1")
WeekNumber() — given a MT4 datetime, returns the week number since 1 Jan 1970, week is assumed to start on Sunday
YMDtoDate() — converts 3 integers (year, month and day) to a MT4 date/time value
d() — outputs up to 8 values to the file /EXPERTS/FILES/DEBUG.TXT, appending data to the end of the file
dd() — outputs up to 8 values to the file /EXPERTS/FILES/DEBUG.TXT, creating a new file
err_msg() — returns a full description of an error, given its error code number
log() — outputs up to 8 values for viewing using Microsoft's DebugView facility (see here for more info)
Oct 31, 2011: updated further. Many new functions added since the last update.
June 6, 2009: I've added some more functions. Two that might be particularly useful are:
NumberToStr(n,mask)
DateToStr(date,mask)
OutputString = NumberToStr(n,"mask")
This formats a number (int or double) into a string, performing alignment, rounding, inserting commas (0,000,000 etc), floating signs, currency symbols, and so forth, according to the instructions provided in the 'mask'.
The basic mask is "n" or "n.d" where n is the number of digits to the left of the decimal point, and d the number to the right,
e.g. NumberToStr(123.456,"5") will return "<space><space>123"
e.g. NumberToStr(123.456,"5.2") will return "<space><space>123.45"
Other characters that may be used in the mask:
Note that when you compile your EA/indicator/script, you'll get a number of warning messages ("Function XXX is not referenced and will be removed from exp-file"). These can be safely ignored. All they are saying is that any functions you're not using will not be compiled into the .ex4 file (which is good, as it keeps the executable code efficient). However, any unused functions remain in your .mq4 source, should you ever wish to use them at some future point.
Enjoy!
David
_______________________________
Basically, you have two options:
If you want to compile using build 509: use the attached .mqh files, and you can get the build 509 compiler here.
OR
If you want to use the latest MQL4 compiler: you can use the .mqh files generously created by pips4life here.
_______________________________
TERMS AND CONDITIONS
By downloading and using the software provided in this thread, you agree to the following:
All code is supplied FREE of charge. It may NOT be sold or distributed commercially.
Software is offered on an 'as is' basis. I'm not offering a programming or troubleshooting service. Source code is attached if anybody wants to make fixes or enhancements (you will also need the MQH libraries and the build 509 MetaEditor/compiler as explained and attached here).
I offer no warranty that the software is fit for purpose, or free of errors. Download and use the code at your own risk; I accept no liability for computer damage or financial losses.
Pips4life has very generously updated these functions so that they will work correctly in MT4 builds 600 or later. You can download the new versions of the files, and also read his notes and disclaimers, here. As far as I know, the functions should continue to work exactly as they did before.
____________________________
INSTRUCTIONS
Updated January 7, 2014:
I've added more functions since this post was last updated.
For the complete list of functions, refer to the 'hanover --- function header (np).mqh' file.
Updated August 7, 2013:
I've added maybe 5-6 more functions since this post was last updated.
For the complete list of functions, refer to the 'hanover --- function header (np).mqh' file.
Updated Jan 28, 2013:
1. Added the following functions:
iRegr() — returns &pips, &slope, &stdev of regression curve defined by symbol, period, poly degree, #points, st devs, hist shift
PlotTL (objname, delete, window#, time1, price1, time2, price2, color, width, style, ray, backg, vis); // Plot trendline
PlotBox (objname, delete, window#, time1, price1, time2, price2, color, width, style, backg, vis); // Plot rectangle
PlotArrow (objname, delete, window#, time1, price1, color, size, code, backg, vis); // Plot arrow
PlotVL (objname, delete, window#, time1, color, width, style, backg, vis); // Plot vertical line
PlotHL (objname, delete, window#, price1, color, width, style, backg, vis); // Plot horizontal line
PlotText (objname, delete, window#, time1, price1, text, color, size, font, angle, backg, vis); // Plot text
PlotLabel (objname, delete, window#, corner, hpos, vpos, text, color, size, font, angle, backg, vis); // Plot text label
Updated Jan 3, 2013:
1. Added the following functions:ColorToStr() — converts a MT4 color value to its equivalent string token (e.g. "AliceBlue", "BurlyWood", "Red", "b101g96r44" etc)
Updated Oct 11, 2012:
1. Added the following functions:
DayNumber() — given a MT4 datetime, returns number of days since 1 Jan 1970WeekNumber() — given a MT4 datetime, returns number of weeks since 1 Jan 1970
MonthNumber() — given a MT4 datetime, returns number of months since 1 Jan 1970
Updated Sept 15, 2012:
1. Added StrToColorArray() function.
Updated April 28, 2012:
1. Added MathFactorial() function.
2. Fixed bug in StrToDoubleArray(), StrtoIntegerArray(), StrToStringArray() functions, which were previously not handling null strings correctly.
Updated April 22, 2012:
During my time as a MT4 programmer, I have extended the MQL4 language by adding more than 80 new functions. These perform string, number, date and array manipulations, that IMO should be a basic part of any good programming language. Here is a list, and brief description, of these functions:
AppendIfMissing() — appends a character to a string if it's not already the rightmost character
AppendIfNotNull() — appends a character to a string if the string is not null
BarConvert() — converts a bar# (candle#) to the equivalent bar# on another timeframe
BaseToNumber() — performs multibase arithmetic: converts a non-base 10 number (string) to a base 10 integer
BoolToStr() — converts a boolean value to "true" or "false"
ColorToStr() — converts a MT4 color value to its equivalent string token (e.g. "AliceBlue", "BurlyWood", "Red", "b101g96r44" etc)
DateToStr() — formats a MT4 date/time value to a string, using a very sophisticated format mask
DatesToStr() — performs multiple DateToStr() operations in a single function
DayNumber() — given a MT4 datetime, returns number of days since 1 Jan 1970
DebugDoubleArray() — unloads a set of values from a double array, prefixed by the element number, to a single string
DebugIntegerArray() — unloads a set of values from an int array, prefixed by the element number, to a single string
DebugStringArray() — unloads a set of values from a string array, prefixed by the element number, to a single string
DivZero() — returns 0 instead of 'divide by zero' error, if denominator evaluates to 0
DoubleArrayToStr() — unloads a set of values from a double array to a single string, inserting a specified delimiter between the values
EasterDay() — returns the MT4time value of Easter Sunday for the given year
ExpandCcy() — expands a curency symbol name, e.g. "EJ" to "EURJPY"
ExtractAlpha() — returns alphabetic (or other) characters in a string
ExtractUnique() — returns 1 occurrence only of each char in a string; result may be optionally sorted asc/desc
FileSort() — shell sorts an ASCII text file, rewriting the file with its records in alphanumeric order
GetHash() — calculate and return checksum of a string
GetVisibility() — returns suitable OBJPROP_TIMEFRAMES value from a timeframes string (e.g. "M1,M5,M15")
IntegerArrayToStr() — unloads a set of values from an int array to a single string, inserting a specified delimiter between the values
iRegr() — returns &pips, &slope, &stdev of regr curve defined by pair, tf, poly degree, #points, st devs, hist shift
ListGlobals() — lists all GlobalVariables and their values, to a string
ListOrders() — lists all orders of your chosen stati (open/pending/closed/deleted) to a string
LookupDoubleArray() — looks up a numeric value in a double array, returning the element number (if found)
LookupIntegerArray() — looks up a numeric value in an int array, returning the element number (if found)
LookupStringArray() — looks up a string value in a string array, returning the element number (if found)
MathFactorial() — calculates a factorial n(n-1)(n-2)...1 using a recursive technique
MathFix() — returns the value of N, rounded to D decimal places (fixes precision bug in MQL4 MathRound)
MathInt() — returns the value of N, rounded DOWN to D decimal places (fixes precision bug in MQL4 MathFloor)
MathSign() — returns the sign (-1,0,+1) of a number
MonthNumber() — given a MT4 datetime, returns number of months since 1 Jan 1970
NumberToBase() — performs multibase arithmetic: converts a base 10 integer to a non-base 10 number (string)
NumberToStr() — formats a numeric (int/double) value to a string, using a very sophisticated format mask
NumbersToStr() — performs multiple NumberToStr() operations in a single function
OrderStatus() — given a ticket number, returns the order status (O=open, P=pending, C=closed, D=deleted, U=unknown)
ReadWebPage() — reads a page from a specified URL into a string
ReduceCcy() — reduces a currency symbol name, e.g. "EURJPY" to "EJ"
ReturnDay() — returns the MT4time value of the (e.g.) 3rd Sunday after 14 Feb 2011
ShellsortDoubleArray() — shell sorts an array of double values into ascending or descending sequence
ShellsortIntegerArray() — shell sorts an array of int values into ascending or descending sequence
ShellsortString() — shell sorts the characters in a string into ascending or descending ASCII sequence
ShellsortStringArray() — shell sorts an array of string values into ascending or descending ASCII sequence
StrToBool() — converts a suitable string (T(rue)/t(rue)/F(alse)/f(alse)/1) to a boolean value
StrToChar() — returns the decimal ASCII value of a 1 byte string (inverse of MQL4's CharToStr())
StrToColor() — converts a string (color name, RGB values, etc) to a MQL4 color
StrToColorArray() — loads a color array from a delimiter-separated set of string values (e.g. "Blue,Green,Red"); returns the number of array elements loaded
StrToDate() — converts a number of different string patterns to a MT4 date/time value
StrToDoubleArray() — loads a double array from a delimiter-separated set of string values (e.g. "1,2,3"); returns the number of array elements loaded
StrToIntegerArray() — loads an int array from a delimiter-separated set of string values (e.g. "1,2,3"); returns the number of array elements loaded
StrToNumber() — strips all non-numeric characters from a string, returning a numeric (int/double) value
StrToStr() — left/right/center aligns, or truncates, a string, using a very sophisticated format mask
StrToStringArray() — loads a string array from a delimiter-separated set of string values (e.g. "1,2,3"); returns the number of array elements loaded
StrToTF() — converts a timeframe string to a number (e.g. "M15" to 15)
StringArrayToStr() — unloads a set of values from an string array to a single string, inserting a specified delimiter between the values
StringDecrypt() — unencrypts a string that was previously encrypted using StringEncrypt()
StringEncrypt() — encrypts a string
StringExtract() — extracts the content of string between 2 specified delimiters
StringFindCount() — returns the number of occurrences of a certain substring in a string
StringInsert() — inserts characters into a given position in a string
StringLeft() — returns the leftmost characters, or all but the N rightmost characters, of a string
StringLeftExtract() — extracts N characters from a string, counting from the left
StringLeftPad() — inserts specified padding characters at the beginning of a string
StringLeftTrim() — removes all leading spaces from a string
StringLower() — converts all alphabetic characters in a string to lowercase
StringOverwrite() — overwrites characters in a given position of a string
StringRepeat() — returns a given string, repeated N times
StringReplace() — replaces substring in a string with another substring
StringReverse() — reverses a string, e.g. "ABCDE" becomes "EDCBA"
StringRight() — returns the rightmost characters, or all but the N leftmost characters, of a string
StringRightExtract() — extracts N characters from a string, counting from the right
StringRightPad() — appends specified padding characters to the end of a string
StringRightTrim() — removes all trailing spaces from a string
StringTranslate() — translates characters in a string, given a full translation table
StringTrim() — removes all (leading, trailing and embedded) spaces from a string
StringUpper() — converts all alphabetic characters in a string to uppercase
StrsToStr() — performs multiple StrToStr() operations in a single function
TFToStr() — converts a number to a timeframe string (e.g. 1440 to "D1")
WeekNumber() — given a MT4 datetime, returns the week number since 1 Jan 1970, week is assumed to start on Sunday
YMDtoDate() — converts 3 integers (year, month and day) to a MT4 date/time value
d() — outputs up to 8 values to the file /EXPERTS/FILES/DEBUG.TXT, appending data to the end of the file
dd() — outputs up to 8 values to the file /EXPERTS/FILES/DEBUG.TXT, creating a new file
err_msg() — returns a full description of an error, given its error code number
log() — outputs up to 8 values for viewing using Microsoft's DebugView facility (see here for more info)
Oct 31, 2011: updated further. Many new functions added since the last update.
June 6, 2009: I've added some more functions. Two that might be particularly useful are:
NumberToStr(n,mask)
DateToStr(date,mask)
OutputString = NumberToStr(n,"mask")
This formats a number (int or double) into a string, performing alignment, rounding, inserting commas (0,000,000 etc), floating signs, currency symbols, and so forth, according to the instructions provided in the 'mask'.
The basic mask is "n" or "n.d" where n is the number of digits to the left of the decimal point, and d the number to the right,
e.g. NumberToStr(123.456,"5") will return "<space><space>123"
e.g. NumberToStr(123.456,"5.2") will return "<space><space>123.45"
Other characters that may be used in the mask:
- Including a "-" anywhere to the left of "n.d" will cause a floating minus symbol to be included to the left of the number, if the nunber is negative; no symbol if positive
- Including a "+" anywhere to the left of "n.d" will cause a floating plus or minus symbol to be included, to the left of the number
- Including a "-" anywhere to the right of "n.d" will cause a minus to be included at the right of the number, e.g. NumberToStr(-123.456,"3.2-") will return "123.46-"
- Including a "(" or ")" anywhere in the mask will cause any negative number to be enclosed in parentheses
- Including an "R" or "r" anywhere in the mask will cause rounding, e.g. NumberToStr(123.456,"R3.2") will return "123.46"; e.g. NumberToStr(123.7,"R3") will return "124"
- Including a "$", "€", "" or "" anywhere in the mask will cause the designated floating currency symbol to be included, to the left of the number
- Including a "," anywhere in the mask will cause commas to be inserted between every 3 digits, to separate thousands, millions, etc at the left of the number, e.g. NumberToStr(123456.789,",6.3") will return "123,456.789"
- Including a "Z" or "z" anywhere in the mask will cause zeros (instead of spaces) to be used to fill any unused places at the left of the number, e.g. NumberToStr(123.456,"Z5.2") will return "00123.45"
- Including an asterisk "*" anywhere in the mask will cause asterisks to be used to fill any unused places at the left of the number, e.g. NumberToStr(123.456,"*5.2") will return "**123.45"
- Including a "B" or "b" anywhere in the mask ("blank if zero") will cause the entire output to be blanks, if the value of the number is zero
- Including a "~" anywhere in the mask will cause a tilde to be output, if overflow occurs (the value of n in "n.d" is too small to allow the number to be output in full)
- Including a "L" or "l" anywhere in the mask will cause the output to be left aligned in the output field, e.g. NumberToStr(123.456,"L5.2") will return "123.45<space><space>"
- Including a "T" or "t" anywhere in the mask will cause the output to be left aligned in the output field, and trailing spaces trimmed e.g. NumberToStr(123.456,"T5.2") will return "123.45"
- Including a ";" anywhere in the mask will cause decimal point and comma to be juxtaposed, e.g. NumberToStr(123456.789,";,6.3") will return "123.456,789"
Any combination of the above can be used in the mask. Feel welcome to experiment.
OutputString = DateToStr(date,"mask")
This converts an MT4 date(/time) value to a formatted string, according to the instructions in the 'mask'.
- A "d" in the mask will cause a 1-2 digit day-of-the-month to be inserted in the output, at that point
- A "D" in the mask will cause a 2 digit day-of-the-month to be inserted in the output, at that point
- A "m" in the mask will cause a 1-2 digit month number to be inserted in the output, at that point
- A "M" in the mask will cause a 2 digit month number to be inserted in the output, at that point
- A "y" in the mask will cause a 2 digit year to be inserted in the output, at that point
- A "Y" in the mask will cause a 4 digit (Y2K compliant) year to be inserted in the output, at that point
- A "W" in the mask will cause a day-of-the week ("Monday", "Tuesday", etc) description to be inserted in the output, at that point
- A "w" in the mask will cause an abbreviated day-of-the week ("Mon", "Tue", etc) description to be inserted in the output, at that point
- A "N" in the mask will cause a month name ("January", "February", etc) to be inserted in the output, at that point
- A "n" in the mask will cause an abbreviated month name ("Jan", "Feb", etc) to be inserted in the output, at that point
- A "h" in the mask will cause the hour-of-the-day to be inserted in the output, as 1 or 2 digits, at that point
- A "H" in the mask will cause the hour-of-the-day to be inserted in the output, as 2 digits (with placeholding 0, if value < 10), at that point
- An "I" or "i" in the mask will cause the minutes to be inserted in the output, as 2 digits (with placeholding 0, if value < 10), at that point
- A "S" or "s" in the mask will cause the seconds to be inserted in the output, as 2 digits (with placeholding 0, if value < 10), at that point
- An "a" in the mask will cause a 12-hour version of the time to be displayed, with "am" or "pm" at that point
- An "A" in the mask will cause a 12-hour version of the time to be displayed, with "AM" or "PM" at that point
- A "T" in the mask will cause "st" "nd" rd" or "th" to be inserted at that point, depending on the day of the month e.g. 13th, 22nd, etc
- All other characters in the mask will be output, as is
Examples: if date (a MT4 datetime variable) is June 04, 2009, then:
- DateToStr(date,"w m/d/Y") will output "Thu 6/4/2009"
- DateToStr(date,"Y-MD") will output "2009-0604"
- DateToStr(date,"d N, Y is a W") will output "4 June, 2009 is a Thursday"
- DateToStr(date,"W D`M`y = W") will output "Thursday 04`06`09 = Thursday"
Instructions:
1. Download the attached .mqh files into your ..../[MT4]/experts/include folder.
2. Simply copy the #include statements, exactly as shown in the boxed sample below, into the beginning and end of your EA/indicator/script, and then the latter has access to all of the additional functions.
Inserted Code
//+------------------------------------------------------------------+ //| sample.mq4 | //+------------------------------------------------------------------+ // copy the #include statement to the start of your program code #include <hanover --- function header (np).mqh> //+------------------------------------------------------------------+ int start() { //+------------------------------------------------------------------+ MessageBox(NumberToStr(20,"'['-5.3']'")); return(0); } //+------------------------------------------------------------------+ // copy the #include statement to the end of your program code #include <hanover --- extensible functions (np).mqh>
Note that when you compile your EA/indicator/script, you'll get a number of warning messages ("Function XXX is not referenced and will be removed from exp-file"). These can be safely ignored. All they are saying is that any functions you're not using will not be compiled into the .ex4 file (which is good, as it keeps the executable code efficient). However, any unused functions remain in your .mq4 source, should you ever wish to use them at some future point.
Enjoy!
David
_______________________________
Basically, you have two options:
If you want to compile using build 509: use the attached .mqh files, and you can get the build 509 compiler here.
OR
If you want to use the latest MQL4 compiler: you can use the .mqh files generously created by pips4life here.
_______________________________
TERMS AND CONDITIONS
By downloading and using the software provided in this thread, you agree to the following:
All code is supplied FREE of charge. It may NOT be sold or distributed commercially.
Software is offered on an 'as is' basis. I'm not offering a programming or troubleshooting service. Source code is attached if anybody wants to make fixes or enhancements (you will also need the MQH libraries and the build 509 MetaEditor/compiler as explained and attached here).
I offer no warranty that the software is fit for purpose, or free of errors. Download and use the code at your own risk; I accept no liability for computer damage or financial losses.
Attached File(s)
hanover --- extensible functions (np).mqh
122 KB
|
3,344 downloads
|
Uploaded Apr 29, 2016 8:40am
hanover --- function header (np).mqh
14 KB
|
2,979 downloads
|
Uploaded Apr 29, 2016 8:41am