![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Given:
In the init() function of the EA, an MQL PSP generator is initialized: MathSrand(...). When the terminal starts, several (for clarity, let's say three) copies of the Expert Advisor are loaded from the template. The loading is fast, so it is very likely (and almost always is) that the TimeLocal() and TimeCurrent() functions return the same values in all copies.
Question:
What tricks are there to get the PRNG to initialise different numbers in different copies of the EA? In other words, where (with minimal programming effort) to get the element of randomness?
Given:
In the init() function of the EA, an MQL PSP generator is initialized: MathSrand(...). When the terminal starts, several (for clarity, let's say three) copies of the Expert Advisor are loaded from the template. The loading is fast, so it is very likely (and almost always is) that the TimeLocal() and TimeCurrent() functions return the same values in all copies.
Question:
What tricks are there to get the PRNG to initialise different numbers in different copies of the EA? In other words, where (with minimal programming effort) to get the element of randomness?
GetTickCount ?
might work, but not for sure...
A millisecond for a programme can be an eternity.)
might work, but not for sure...
option 2 - use global variables to create "semaphores" to initialise the experts in sequence.
Question about fetching rows from dll in mql.
function mysql_fetch_row from libmysql.dll returns type MYSQL_ROW
This type is defined as: typedef char** MYSQL_ROW
How do I get to this returned string array?
Are the dimensions of the array known?
but the length of each row is not.
There's another thing in that link example - getting a *lengths pointer.
, row[i] ? row[i] : "NULL"); }It turns out to be an array too... But how to get to it...
here's what you get in MQL when just passing result of mysql_fetch_row to string
p0ƒu0ƒ;1;a
where
p0ƒu0ƒ is the address (8 bytes) of the string
;1;a is its usable data
but if you set it to int, then instead of p0ƒ the address is 42152040
If the pointer to the string does not change while the program is running, you can return the pointer to the string without copying it to the buffer.
So there is no way to do it in MQL? Not even MQL5?
If the pointer to the string does not change while the program is running, you can return the pointer to the string without copying it to the buffer.
Simply