View Full Version : Handy MQL4 utility functions
Pips4Life, thank you for sharing this and for all your hard work.
I used the revised utility file on assemble 600 to Optimize Hanover's Display Info Indicator but discovered that PlotLabel selectively output only some pops, leaving space for the remaining rows (like the text colour was the same as the backdrop ). Image of output and relevant query in another thread (post7988277)
If anybody has encountered the exact same issue, and discovered that a workaround, it would be great if you can share a few pointers.
Thanks,
Can anyone plz recommend me some graphical and UI making library for MQL4.
Hi all!
Can anyone construct alarm on indicator? Https://www.nigeriaforextrading.com/attachments/1531689021.png To look as an alarm to the colour change
https://www.nigeriaforextrading.com/attachments/1531689030390613064.mq4
Hello every body
Does any body know how do we see implementation of MT4 internal functions? For example MathPow, timeDayOfweek or etc..
I searched in meta trader folders couldn't find these records
alilacamicays
12-15-2022 22:10,
UPDATE (Aug 11, 2014): Pips4life has very generously updated these functions in order that they will work correctly in MT4 builds 600 or afterwards. You may download the new versions of the documents, and read his notes and disclaimers, here. So far as I know, the functions should continue to work exactly as they did before. NOTE (Jan 31, 2014): Any indicators or EAs I have contributed to this thread will likely no longer work in the latest MT4 construct that's (if I know... Hi Hanover, I´m from Brazil and I need talk to youpersonally.
Can you give me your e-mail?
Due
Llkammm93
12-15-2022 22:20,
Announcing: New v3 Upgrades (b600 ) to's utility Works in my thread:
Altered, useful MQ4 utilities, indicators, and related tips () (here)
https://www.nigeriaforextrading.com/bitcoin-talk-and-cryptocurrencies/242-test-breakout-system.html
New Documents are posted, with new names as follows:For gt;= b600 (currently MT4 is at b1065):-- serve header b600 (np).mqh -- extensible functions b600 (np).mqh For b509: (Mostly same as above, but with slight changes back to 509. It's easier to maintain if their almost identical)-- serve header b509 (np).mqh -- extensible functions b509 (np).mqh These are based on the 2016-04-29 documents posted by (in post#1 of the thread).
These v3 documents have solved a significant bug (in v2, my very first b600 variant ), that did not work with some of the indicators. This one may work with Display Info All Pairs, that had problems with the earlier version. (NOTE: The Display Info All Pairs.mq4 must ALSO be upgraded to b600!! I've posted my b600 variation from the other thread ).
Hi,
I Want to Place date in TextProperties for DLB.
I want it to be like: n D, Y
How do I put this in the common format? Am having troubles with commas.
Plus, can it be feasible to possess Box height 1st, then week, then HL in the output?
pablolmga
12-15-2022 22:35,
I need to Place date in TextProperties for DLB. I need it to be similar to: n D, Y should I place this in the arrangement? Am having problems with commas. That's because the commas are used as field separators in this circumstance. But most fonts permit the usage of Alt-130 for a replacement for a comma, i.e. hold down the Alt key while you type 0130
e.g. put TextProperties to something like
Verdana,9,Silver,4,HL,n D8218; Y,T3.5';',0
at which the highlighted character is Alt-130https://www.nigeriaforextrading.com/attachments/15316890401276340223.png
Plus, can it be feasible to have Box height 1st, then week, then HL in the output? This can be accomplished only by changing the program code.
quote That's because the commas act as field separators in this circumstance. However, most fonts allow the use of Alt-130 for a replacement for a comma, i.e. hold down the Alt key as you sort 0130 e.g. put TextProperties to something such as Verdana,9,Silver,4,HL,n D' Y,T3.5';',0 where the highlighted character is Alt-130picture quote This can be achieved simply by changing the code.
Very helpful, thanks https://www.nigeriaforextrading.com/attachments/1531689022.png
pablolmga
12-15-2022 22:53,
New version uploaded: 7 new functions added. See post #1 for download documents and detailed info.
Experienced an issue when attempting to compile Sessions.mq4 (https://www.nigeriaforextrading.com/bitcoin-talk-and-cryptocurrencies/119-ea-capable.html)
its concerning the mqh function DayNumber, I get:'(' - function definition unexpected
(experts/include/ -- extensible functions.mqh (6, 14) )
the terminal employed is r482; and I cant see the solution to fix it.
Experienced an issue while attempting to compile Sessions.mq4 (https://www.nigeriaforextrading.com/trading-discussion/45-esignal-cqg-vttrader.html) its about the mqh function DayNumber, I get:'(' - function definition sudden (experts/include/ -- extensible functions.mqh (6, 14) ) the terminal used is r482; and I cant see the way to fix it. Compiles for me, I followed the instructions, no problems.
ivan.lopwzp
12-15-2022 23:17,
Hi,
just a little feedback nothing really important. Could not PM you so that I post it here
1.
On Your: Shellsort functions you appear to have left over a factor k that's never utilized.
2.
The ShellsortIntegerArray() function Appears to be considerably slower (approximately 10 times or so) compared to the MT4 ArraySort() on an Integer Array
for the MT4 function: ArraySort http://docs.mql4.com/array/ArraySort
Cheers
Ati
Hi Hanover,
Thanks for sharing your Handy utility works. I would like to save time in coding my own custom indicator by using your handy functions.
Please give me some specific directions about the best way best to put your library works into work.
For example, in purpose PlotText I browse:
PlotText (objname, delete, window, time1, price1, text, color, size, font, angle, backg, vis);
I do not understand delete is what for.
Thank you for your help.
Hi Hanover, Thank you for sharing your own Handy utility functions. I want to save time in coding my own customized indicator with your handy functions. Please provide me some specific instructions about the best way best to place your library functions into work. For instance, in purpose PlotText I browse: PlotText (objname, delete, windowtime1, price1, text, colour, font, font, angle, backg, vis); I do not know delete is what for. Thanks for your help. fareastol-
delete is of type bool. Look at the role to learn what each is.
Inserted Code // ------------------------------------------------------------------ int PlotText(string name, bool del=false, int win=0, datetime dt1=0, double prc1=0, string text=, colour clr=0, int size=0, string font=Arial, double angle=0, bool bg=false, int vis=0) // ------------------------------------------------------------------ if (StringLen(name)lt;1
Thanks a lot, Cyber1. Your instruction is quite clear.
Big pips to you!
pablolmga
12-15-2022 23:49,
New version uploaded: a few new functions added.
See post #1 for download documents and detailed info.
Hanover, most, if not all your function library should work in build 600.
I think there's a bug in the string handling in buld 600 .
The attached test script demones the corruption you get when using your string functions.
There is a bit of chatter on the mql4 forum about corrupt sequences but so far no-one has managed to convince them it's an issue.
https://www.nigeriaforextrading.com/attachments/1531689051.png
https://www.nigeriaforextrading.com/attachments/15316890661396146197.mq4
pablolmga
12-16-2022 03:05,
Hanover, most, if not all your function library must work in build 600. I believe there's a bug in the string handling in buld 600 . The attached test script demones the corruption you get when utilizing your string functions. There is a bit of chatter on the mql4 forum about corrupt strings but far no-one has been able to convince them it is an issue. picture document Many thanks to the info. However, I've no immediate plans to upgrade these purposes to MQL4 build 600 compatibility. For starters, the majority of the array handling functions utilize'pass by reference', which I know is not supported by the build 600 compiler.
Any code I write, at least in the meantime, will be strictly utilizing the build 509 compiler. However, if anybody wants to take these functions and upgrade them to build 600 compatibility, then they're welcome to do so (provided it is not for commercial profit ).
Wonderful share. You are so kind man
wzeke.08
12-16-2022 03:19,
Hanover, most, if not all your function library should work in construct 600. I think there's a bug in the string handling in buld 600 . The attached test script demones the corruption you get when using your series functions. There is a little chatter on the mql4 forum about corrupt strings but far no-one has been able to convince them it is a problem. image document It requires someone to make a small test case.
Ps we now have standard functions StringTrimLeft, StringTrimRight, StringToUpper, StringToLower so substitute these
wzeke.08
12-16-2022 03:29,
quote . For starters, most of the array handling functions use'pass by reference', which I understand is not supported by the construct 600 compiler. As long as you aren't altering the array from the function just add the function call.
If you do happen to alter the array from the function, simply make a copy within the role and use this.
wzeke.08
12-16-2022 03:37,
Hi, you will find two things:
1. StringSubstr is changed. EOL flag is now -1 not 0
2. NumberToStr is calling StringSubstr(str,start_pos,span ) using a negative start_pos.
Outstr = StringSubstr(outstr,StringLen(outstr)-9-nleft,nleft 1 nright-dotadj);
When this happens new MQL4 missing the plot, I'm not 100% sure exactly what old MQL4 does, I'm guessing forced a zero? I would replace all calls to StringSubstr(a,b,c) with calls to StrSubstrOld(a,b,c)
string StringSubstrOld (string x,int a,int b=-1)
if (a lt; 0) a= 0; // Stop odd behavior
if (blt;=0) b = -1; // new MQL4 EOL flag
reunite StringSubstr (x,a,b);
I would also change the following to make the most of library functions: (or even in the case of StringLeftTrim just call the library function StringLeftTrim right )
string StringLeftTrim (string str)
reunite StringTrimLeft (str);
string StringTrim (string str)
reunite StringTrimLeft (StringTrimRight (str));
string StringUpper (string str)
StringToUpper (str);
return str;
there's still a dual -ve appearing on your test. Not sure why...
EDIT:
PS This is really really shoddy work from MQ. How many developer hours will be wasted with matters like this. The compiler should flag or induce exactly the same behavior if is not present.
We shouldn't be expected to trawl through debuggers and documentation to get smaller differences like this.
MQ must :
1. Make lack of property rigorous 100% back compatible...
2. Add compiler warning if function has shifted
3. Produce a comprehensive migration guide.
pablolmga
12-16-2022 03:44,
quote Provided that you aren't modifying the array in the role just insert in the function call. Simply make a copy within the role Should you happen to alter the array in the function and use this. Many thanks for your explanations.
Llkammm93
12-16-2022 03:51,
2 Attachment(s) ATTENTION, FANS OF HANOVER'S MT4 FILES!!
Hanover isn't doing some more MT4 programming and zero further support of his most applications because build 600 . I went ahead and made edits myself into his functions and headers documents, using construct 670, BUT IN NO WAY AM I going to measure in David's enormous shoes and keep support!!!
The updated documents are provided here, as-is, with no expectation of further maintenance or support. Use at your own risk! Neither the author(s) or contributor(s) (me or anybody else) assume any liability whatsoever! No exceptions!
If you find further changes are needed, please don't hesitate to upgrade the files, upload them , and explain what and why you made adjustments. Fyi, if these are combined with other MT4 documents that provided elsewhere, it might well be that this really is when the problems will surface, which will necessitate bug fixes. Whatever is required is your duty!
Important: See the text near the peak of the functions file (reproduced below) to see what changes you're most likely to need to create to's other MT4 documents which make use of them Include documents.
Install them into your MQL4/Include/ folder. If you don't understand where that is, click Files Open Data Folder. (If you are not using the /portable option when conducting build 600 , well, you need to be, but hunt elsewhere on how to do it. With /portable, the Data folder that I end up using is below C:/Users/myname/MT4 myBroker/MQL4/... ).
Inserted Code /* Version Background USE ONLY AT YOUR OWN RISK!!! The user assumes all liability for everything. The author(s) contributor(s) have ZERO liability!! NO EXCEPTIONS! Updated on 2014-Aug-04 by (Kent) for gt;600 support. HOWEVER, do NOT contact me for further aid, nor David, who has made it abundantly clear he's done with MT4 programming! My changes are provided as-is. If you make upgrades, post them to David's ribbon: Functional MQL4 utility works http://www.forum.com/showthread.php?t=165557 IMPORTANT! Should you combine this document with another of David's .mt4 source documents, then ABSOLUTELY create these changes using Replace, while enabling* options whole word and match instance: 1 ). Change his use of StringReplace into stringReplaceOld. (lower-case leading s). You will likely NOT receive any compiler error or warning, but the new MT4 function does not behave the same as Davids' does!! 2. Change StringSubstr into stringSubstrOld, because new MT4 expects different 3rd arument worth (-1 instead of 0); also it MIGHT corrupt sequences if the 2nd argument is suddenly lt;0. You won't find any compiler error or warning, but make the shift! 3. Change his use of variable name char to be s_char instead. Same with every other such key phrases. The compiler will give mistakes until fixed. 4. Repair all other compiler errors and remove warnings if possible, doing whatever needs to be done, then upload your changes to David's utility ribbon above. (. . .and elsewhere should you so choose). The local-variable names below are occasionally the same as global-variable names utilized. In general, an individual can usually ignore warnings which say: declaration of'varname' hides global declaration online XX, in File AAA, Line YY, Column ZZ Original: 2014-and-earlier: Hanover of all forum.com ALL COPYRIGHTS RESERVED! Decision / https://www.nigeriaforextrading.com/bitcoin-talk-and-cryptocurrencies/111-hidden-sl-tp.html
https://www.nigeriaforextrading.com/bitcoin-talk-and-cryptocurrencies/248-better-volume-indicator-prorealtime-users.html
pablolmga
12-16-2022 04:00,
ATTENTION, FANS OF HANOVER'S MT4 FILES!! Hanover is not doing some more MT4 programming.... Many thanks for all of your hard work. Https://www.nigeriaforextrading.com/attachments/1531689051.png
I expect that other developers will continue to find the functions useful.
nalhalienalhalie
12-16-2022 04:08,
I expect that other programmers will continue to find the functions useful. They certainly are, personally I've used at least some of these thanks a lot!!! https://www.nigeriaforextrading.com/attachments/1531689051.png
Fajagama
12-16-2022 04:16,
Wonderful tooling Hanover, thank you.
I've compiled in Mt4 build 600 a number of the string parsing works but I am having difficulty getting the call format StrToStringArray(str, str, str, str) to process.
Anyone have a working example of a build 600 call they might share? Https://www.nigeriaforextrading.com/attachments/1531689051.png
Thank you Beforehand,
pablolmga
12-16-2022 04:23,
Nice tooling Hanover, thank you. I have compiled in Mt4 construct 600 a number of this string parsing functions but I am having difficulty getting the call format StrToStringArray(str, str, str, str) to process. Anyone have a working example of a construct 600 call they may talk about? Https://www.nigeriaforextrading.com/attachments/1531689051.png Thanks beforehand, afp Sorry, I only saw your post now. If you are still about and seeking an answer, see post #56.
alfokseka83
12-16-2022 04:28,
See I m making a grid trading platform
n presently theres a newbie at mql4...
what so much I hav achived is sending autmatic order based on my calculations.
However my system ship order again and again....
Example
if I run expert it ship such as this
buy limitation 1.40000
buy limitation 1.39800
buy limitation 1.39600
buy limitation 1.39400
buy limitation 1.39200
then it begin untill I stop pro
1.40000
.... . . . . .
1.39200
again. .
N cant utilize break be my system will be lasts...
so I want a loop in my specialist which run following order ship. . N remove multiple pending limitations
and
supose if struck 1.40000 its tp is 1.40400 n market moves
to say 1.40200
it send a limit order in 1.40000
I also want a funtion that this kind of order...
it shud only allow 1.4000 newlimit to be ship once 1.4000 open order tpis achived n it doestnt exist within an open order
pablolmga
12-16-2022 04:40,
see I m making a grid trading system
n at present theres a newbie in mql4... Thanks for taking the time to describe this. It seems complicated. I am too busy with other projects to undertake any new outside job, unless the task is quite simple (i.e. will take less than 30 minutes to code and test) or I believe it will benefit my trading in some way.
If you're attempting to do almost all of the coding yourself, the following http://book.mql4.com/trading/index (additionally http://book.mql4.com/samples/expert), which clarifies the MQL4 code required to create, modify, close and delete orders, might help you.
I've written a package that, among its many features, allows multiple entries at equally spaced levels, and may also permit simultaneous modifying and closing/deleting of numerous open/pending orders. However, it is not an EA, and hence will not babysit your trades. And it is not free (it's accessible through the industrial forum).
Personally I do not trade grid programs. There are lots of grid programs accessible at forum. If you type'grid' to FF's search engine, you get a lot of hits. Perhaps could adapt his grid to suit your requirement.
alfokseka83
12-16-2022 04:50,
I dont think its that complicated... if we hav a verbal talk... I could expln u more.... I dont mind. . .it will barely take a couple hours...
Thank you so much, David!
pablolmga
12-16-2022 05:07,
I've updated the code section is post #1 into the list of functions. There are now over 70 utility functions available.
There is also an index of functions in the end.
David
Hello,
How Can I call your StrToIntegerArray Work?
I really don't understand how to place the factor for int a[]. How do I print a test with this function?
#include lt;HandyUtilityFunctions.mqhgt;
extern series TP=18,46,72;
StrToIntegerArray(TP,?? ,,, 0);
// ----------------------------------------------------------------------------
//| int StrToIntegerArray(string str, int a[], string delim=,, int init=0)
// ----------------------------------------------------------------------------
// Breaks down a single string into integer array'a' (elements delimited by'delim')
// e.g. series is 1,2,3,4,5; if delim is, then the result will be
// a[0]=1 a[1]=2 a[2]=3 a[3]=4 a[4]=5
// Unused array elements are initialized by significance in'init' (default is 0)
// ----------------------------------------------------------------------------
int StrToIntegerArray(string str, int a[], string delim=,, int init=0)
for (int I=0; ilt;ArraySize(a); I )
a[I] = init;
int z1=-1, z2=0;
if (StringRight(str,1)! = delim) str = str delim;
for (I=0; ilt;ArraySize(a); I )
z2 = StringFind(str,delim,z1 1);
a[I] = StrToNumber(StringSubstr(str,z1 1,z2-z1-1));
if (z2 gt;= StringLen(str)-1) break;
z1 = z2;
return(StringFindCount(str,delim));
pablolmga
12-16-2022 05:20,
Hi,
How do I call your StrToIntegerArray function? .... SorryI just saw your post now. I do not subscribe to ribbons.
Anyhow, if you're still about, here is your answer to your query:
Inserted Code int TP_array#91;3#93;; string TP = 18,46,72; StrToIntegerArray(TP,TP_array); MessageBox(DebugIntegerArray(TP_array)); That duplicates the content of string TP into the first 3 elements of the range TP_array, and then outputs the range articles in a message box, as an investigation:
[0]=18.00,[1]=46.00,[two ]=72.00
David
pablolmga
12-16-2022 05:26,
New version uploaded, see post #1 for details.
zigomeibam
12-16-2022 05:35,
Found effect.
Attempt gearing up to zero decimal for worth of 123.456.
i get 123.000
pablolmga
12-16-2022 05:43,
found incorrect effect for MathFix function.
Attempt gearing up to zero decimal for value of 123.456.
I get 123.000 Function is working properly.
Values lower than 123.5 are rounded down to 123.000
Values higher than 123.5 are rounded around 124.000
If you want to round up all worth larger than (for example) 123.000 into 124.000, utilize MathFix(x 0.49999999)
pablolmga
12-16-2022 06:20,
2 Attachment(s) IMPORTANT UPDATE (May 7, 2017):
Pips4life has very generously updated these purposes so they will operate correctly in MT4 builds 600 or later. You can download the new versions of these documents, and also read his notes and disclaimers, here. As far as I know, the functions need to continue to work just as they did before.
____________________________
INSTRUCTIONS
Updated January 7, 2014:</b></b>
I have added more functions since this article was last updated.
For the whole list of functions, refer to the' -- function header (np).mqh' file.
Updated August 7, 2013:
I have added possibly 5-6 more functions since this article was last updated.
For the whole list of functions, refer to the' -- function header (np).mqh' file.
Updated Jan 28, 2013 :
1. Added the following purposes:
iRegr() #8212; yields pips, slope, stdev of regression curve characterized by symbol, period, poly level, #points, st devs, hist shift
PlotTL (objname, delete, window, time1, price1, time2, price2, color, width, style, beam, 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, dimensions, signal, 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 purposes: ColorToStr() #8212; 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 purposes:
DayNumber() #8212; awarded a MT4 datetime, returns number of times since 1 Jan 1970 WeekNumber() #8212; awarded that a MT4 datetime, yields number of weeks since 1 Jan 1970
MonthNumber() #8212; awarded that a MT4 datetime, yields few months since 1 Jan 1970
Updated Sept 15, 2012:
1. Additional StrToColorArray() function.
Updated April 28, 2012 :
1. Additional MathFactorial() function.
2. Fixed bug in StrToDoubleArray(), StrtoIntegerArray(), StrToStringArray() works, which were formerly not handling strings correctly.
Updated April 22, 2012:
Throughout my time as a MT4 programmer, I've extended the MQL4 language by adding more than 80 new purposes. These perform date, number, string and variety manipulations, that IMO should be a part of any programming language. Here is a list, and brief description, of these functions:
AppendIfMissing() #8212; appends a character to a string if it's not already the rightmost character
AppendIfNotNull() #8212; appends a character to a string if the string is not
BarConvert() #8212; converts a bar# (candle#) to the equivalent bar# on another timeframe
BaseToNumber() #8212; performs multibase arithmetic: converts a non-base 10 number (string) to a base 10 integer
BoolToStr() #8212; converts a boolean value to true or false
ColorToStr() #8212; converts a MT4 color value to its equivalent string token (e.g. AliceBlue, BurlyWood, Red, b101g96r44 etc)
DateToStr() #8212; formats a MT4 date/time value to a string, using a very sophistied format mask
DatesToStr() #8212; performs multiple DateToStr() operations in One function
DayNumber() #8212; given a MT4 datetime, returns number of days since 1 Jan 1970
DebugDoubleArray() #8212; unloads a set of values from a double array, prefixed by the element number, to a single string
DebugIntegerArray() #8212; unloads a set of values from an int array, prefixed by the element number, to a single string
DebugStringArray() #8212; unloads a set of values from a string array, prefixed by the element number, to a single string
DivZero() #8212; returns 0 instead of'divide by zero' error, if denominator evaluates to 0
DoubleArrayToStr() #8212; unloads a set of values from a double array to a single string, inserting a specified delimiter between the values
EasterDay() #8212; returns the MT4time value of Easter Sunday for the given year
ExpandCcy() #8212; expands a curency symbol name, e.g. EJ to EURJPY
ExtractAlpha() #8212; returns alphabetic (or other) characters in a string
ExtractUnique() #8212; returns 1 occurrence only of each char in a string; result Might Be optionally sorted asc/desc
FileSort() #8212; shell sorts an ASCII text file, rewriting the file with its records in alphanumeric order
GetHash() #8212; calculate and return checksum of a string
GetVisibility() #8212; returns suitable OBJPROP_TIMEFRAMES value from a timeframes string (e.g. M1,M5,M15)
IntegerArrayToStr() #8212; unloads a set of values from an int array to a single string, inserting a specified delimiter between the values
iRegr() #8212; returns pips, slope, stdev of regr curve defined by pair, tf, poly degree, #points, st devs, hist shift
ListGlobals() #8212; lists all GlobalVariables and their values, to a string
ListOrders() #8212; lists all orders of your chosen stati (open/pending/closed/deleted) to a string
LookupDoubleArray() #8212; looks up a numeric value in a double array, returning the element number (if found)
LookupIntegerArray() #8212; looks up a numeric value in an int array, returning the element number (if found)
LookupStringArray() #8212; looks up a string value in a string array, returning the element number (if found)
MathFactorial() #8212; calculates a factorial n(n-1)(n-2)...1 using a recursive technique
MathFix() #8212; returns the value of N, rounded to D decimal places (fixes precision bug in MQL4 MathRound)
MathInt() #8212; returns the value of N, rounded DOWN to D decimal places (fixes precision bug in MQL4 MathFloor)
MathSign() #8212; returns the sign (-1,0, 1) of a number
MonthNumber() #8212; given a MT4 datetime, returns number of months since 1 Jan 1970
NumberToBase() #8212; performs multibase arithmetic: converts a base 10 integer to a non-base 10 number (string)
NumberToStr() #8212; formats a numeric (int/double) value to a string, using a very sophistied format mask
NumbersToStr() #8212; performs multiple NumberToStr() operations in One function
OrderStatus() #8212; given a ticket number, returns the order status (O=open, P=pending, C=closed, D=deleted, U=unknown)
ReadWebPage() #8212; reads a page from a specified URL into a string
ReduceCcy() #8212; reduces a currency symbol name, e.g. EURJPY to EJ
ReturnDay() #8212; returns the MT4time value of the (e.g.) 3rd Sunday after 14 Feb 2011
ShellsortDoubleArray() #8212; shell sorts an array of double values into ascending or descending sequence
ShellsortIntegerArray() #8212; shell sorts an array of int values into ascending or descending sequence
ShellsortString() #8212; shell sorts the characters in a string into ascending or descending ASCII sequence
ShellsortStringArray() #8212; shell sorts an array of string values into ascending or descending ASCII sequence
StrToBool() #8212; converts a suitable string (T(rue)/t(rue)/F(alse)/f(alse)/1) to a boolean value
StrToChar() #8212; returns the decimal ASCII value of a 1 byte string (inverse of MQL4's CharToStr())
StrToColor() #8212; converts a string (color name, RGB values, etc) to a MQL4 color
StrToColorArray() #8212; 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() #8212; converts a number of different string patterns to a MT4 date/time value
StrToDoubleArray() #8212; 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() #8212; 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() #8212; strips all non-numeric characters from a string, returning a numeric (int/double) value
StrToStr() #8212; left/right/center aligns, or trunes, a string, using a very sophistied format mask
StrToStringArray() #8212; 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() #8212; converts a timeframe string to a number (e.g. M15 to 15)
StringArrayToStr() #8212; unloads a set of values from an string array to a single string, inserting a specified delimiter between the values
StringDecrypt() #8212; unencrypts a string that was previously encrypted using StringEncrypt()
StringEncrypt() #8212; encrypts a string
StringExtract() #8212; extracts the content of string between 2 specified delimiters
StringFindCount() #8212; returns the number of occurrences of a certain substring in a string
StringInsert() #8212; inserts characters into a given position in a string
StringLeft() #8212; returns the leftmost characters, or all but the N rightmost characters, of a string
StringLeftExtract() #8212; extracts N characters from a string, counting from the left
StringLeftPad() #8212; inserts specified padding characters at the beginning of a string
StringLeftTrim() #8212; eliminates all leading characters from a string
StringLower() #8212; converts all alphabetic characters in a string to lowercase
StringOverwrite() #8212; overwrites characters in a given position of a string
StringRepeat() #8212; returns a specified string, repeated N times
StringReplace() #8212; replaces substring in a string with another substring
StringReverse() #8212; reverses a string, e.g. ABCDE becomes EDCBA
StringRight() #8212; returns the rightmost characters, or even all but the N leftmost characters, of a string
StringRightExtract() #8212; extracts N characters from a string, counting from the ideal
StringRightPad() #8212; appends specified padding characters into the end of a string
StringRightTrim() #8212; removes all trailing spaces from a string
StringTranslate() #8212; translates characters in a sequence, given that a complete translation table
StringTrim() #8212; eliminates all (leading, trailing and embedded) spaces from a string
StringUpper() #8212; converts all alphabetic characters in a string to uppercase
StrsToStr() #8212; plays multiple StrToStr() operations in one purpose
TFToStr() #8212; converts a number into a span string (e.g. 1440 into D1)
WeekNumber() #8212; given that a MT4 datetime, returns the week number since 1 Jan 1970, week is supposed to start on Sunday
YMDtoDate() #8212; converts 3 integers (year, month and day) into a MT4 date/time value
d() #8212; outputs up to 8 values into the document /EXPERTS/FILES/DEBUG.TXT, appending data to the end of the document
dd() #8212; outputs up to 8 values into the document /EXPERTS/FILES/DEBUG.TXT, developing a new file
err_msg() #8212; returns a complete description of a mistake, provided its error code number
log() #8212; outputs up to 8 values for viewing using Microsoft's http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx centre (see here for more info)
October 31, 2011: upgraded further. Many new functions added as the last update.
June 6, 2009: I have added some more functions. Two that might be especially useful are:
NumberToStr(n,mask)
DateToStr(date,mask)
OutputString = NumberToStr(n,mask)
This formats a number (int or double) to a string, performing alignment, rounding, inserting commas (0,000,000 etc), floating signs, currency symbols, etc, according to the directions supplied in the'mask'.
The Fundamental mask is n.d where n is the number of digits to the left of the decimal point, and d the amount to the right,
e.g. NumberToStr(123.456,5) will reunite lt;spacegt;lt;spacegt;123
e.g. NumberToStr(123.456,5.2) will reunite lt;spacegt;lt;spacegt;123.45
Other characters that may be Utilized in the mask:Including a - everywhere to the left of n.d can cause a floating minus symbol to be contained into the remaining amount, if the nunber is damaging; no symbol if favorable Including a anywhere to the left of n.d will cause a floating and minus symbol to be contained, to the remaining amount containing a - everywhere to the right of n.d can cause a minus to be contained at the right of the amount, e.g. NumberToStr(-123.456,3.2-) will yield 123.46- containing a ( or ) anywhere in the mask will cause any negative amount to be enclosed in parentheses containing an R or r any place in the mask will cause rounding, e.g. NumberToStr(123.456,R3.2) will reunite 123.46; e.g. NumberToStr(123.7,R3) will reunite 124 Including a $, #8364;, or any place in the mask will cause the floating floating currency symbol to be contained, to the remaining amount Including a, any place in the mask will cause commas to be inserted between each 3 digits, to separate thousands, countless etc in the remaining amount, e.g. NumberToStr(123456.789,,6.3) will reunite 123,456.789 Including a Z or z anywhere in the mask will cause zeros (rather than spaces) to be used to fill any unused areas at the remaining amount, e.g. NumberToStr(123.456,Z5.2) will reunite 00123.45 Including an asterisk * anywhere in the mask will cause asterisks to be used to fill any unused areas at the remaining amount, e.g. NumberToStr(123.456,*5.2) will reunite **123.45 Including a B or b any place in the mask (blank if zero) can cause the entire output to be blanks, if the value of the amount is not any like a ~ anywhere in the mask will cause a tilde to be output, if overflow occurs (the value of in n.d is too small to permit the amount to be output in total ) Including a L or l any place in the mask will cause the output to be left aligned in the output field, e.g. NumberToStr(123.456,L5.2) will reunite 123.45lt;spacegt;lt;spacegt; 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 reunite 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 reunite 123.456,789 Any combination of the above can be used from the mask. Feel welcome to experiment.
OutputString = DateToStr(date,mask)
This converts an MT4 date(/time) value to a formatted string, according to the directions in the'mask'. A d in the mask will cause a 1-2 digit day-of-the-month to be inserted into the output, in the point A D in the mask will cause a 2 digit day-of-the-month to be inserted into the output, at the point A m in the mask will cause a 1-2 digit month amount to be inserted in the output, at the point A M in the mask will cause a 2 digit month amount to be inserted into the output, at the point A y in the mask will cause a 2 digit year to be inserted into the output, at the point A Y in the mask will cause a 4 digit (Y2K compliant) season to be inserted into the output, at the point A W in the mask will cause a day-of-the week (Monday, Tuesday, etc) description to be inserted into the output, in the point A w in the mask will cause an abbreviated day-of-the week (Mon, Tue, etc) description to be inserted into the output, in the point A N in the mask will cause a month name (January, February, etc) to be inserted in the output, in the point A n in the mask will cause an abbreviated month name (Jan, Feb, etc) to be inserted in the output, in the point A h from the mask will cause the hour-of-the-day to be inserted in the output, as 1 or 2 digits, in the point A H in the mask will cause the hour-of-the-day to be inserted into the output, as 2 digits (with placeholding 0, if value lt; 10), in the point An I or in the mask will cause the minutes to be inserted into the output, as 2 digits (with placeholding 0, if value lt; 10), in the point A S or so at the mask will cause the seconds to be inserted into the output, as 2 digits (with placeholding 0, if value lt; 10), in the point An a from the mask will cause a 12-hour version of the Opportunity to be exhibited, with pm or am at the point An A in the mask will cause a 12-hour version of the Opportunity to be exhibited, with AM or PM at the point A T in the mask will cause st nd rd or th to be inserted at the point, depending on the day of the month e.g. 13th, 22nd, respectively All other figures 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 Directions:
1. Download the connected .mqh files in your.../ / [MT4]/ / experts/include folder.
2. Just copy the #include statements as shown in the sample under, in end and the beginning of your EA/indior/script, then the latter has access to each the additional functions.
Inserted Code //p ------------------------------------------------------------------ //| sample.mq4 | //p ------------------------------------------------------------------ // duplicate the #include statement to the start of your program code #include lt; -- serve header (np).mqhgt; // ------------------------------------------------------------------ int start() // ------------------------------------------------------------------ MessageBox(NumberToStr(20,'#91;'-5.3'#93;'-RRB-); return(0); // ------------------------------------------------------------------ // duplicate the #include statement towards the conclusion of your app code #include lt; -- extensible functions (np).mqhgt;
Notice that if you compile your EA/indior/script, then you'll find a range of warning messages (Function XXX isn't referenced and will probably be removed from exp-file). These can be safely dismissed. All they're saying is that some functions you are not using will not be compiled to the .ex4 document (which is great, as it retains the executable code efficient). However, any functions remain on your own. Supply, should you ever desire to use them in some stage.
Appreciate!
David
_______________________________
Basically, you've got two choices:
#61623; If you want to compile using construct 509: use the connected .mqh files, and you can find the construct 509 compiler either here or here.
OR
#61623; 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 applications offered in this thread, you consent to the following:
#61623; Each code is supplied FREE of charge. It may NOT be sold or distributed commercially.
#61623; Software is offered in an'as is' basis. I'm not supplying a programming or troubleshooting service. Source code is connected if anybody wishes to make fixes or enhancements (you may also need the MQH libraries as well as the construct 509 MetaEditor/compiler as explained and connected here).
#61623; I provide no guarantee that the software is fit for purpose, or without any errors. Download and use the code in your own risk; I accept no liability for personal harm or losses.
https://www.nigeriaforextrading.com/trading-system-and-egies/70-supertrend-profitable-forex-ind-50-2000-month.html
https://www.nigeriaforextrading.com/trading-system-and-egies/109-dear-diary.html
Powered by nigeriaforextrading® Version 4.2.5 Copyright © 2026 nigeriaforextrading Solutions, Inc. All rights reserved.