
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
Here is a working example of Adler32 hash function:
The basic code of the function is taken from wikipedia and slightly modified for MQL5. Here is the result of the script:
As you can see, all values returned by this function are absolutely different, although strings themselves don't differ much.
Why ulong and not uint?
And the operations with arrays in this function are extremely inefficient. It is easier to modify the code and divide unicode into two independent symbols - it will be 50 times faster.
3681 ms vs 13822 ms at 3 million runs.... only 4 times different...... but no conversion lossYes, that's right, because 32 bits is an integer, not a long. Although, frankly speaking, I would modify the hash function for 64-bit version. After all, collision probability is less, and it is easy to adjust for magic expert. Although, on the other hand, the current implementation is fully compatible with MQL4 (for it has no long type)
P.S. Wouldn't it be faster, if I convert string to uchar array before looping, and already in loop one by one go through array values? But I think calling StringGetCharacter(buf, n) every time in the loop is too expensive.
Yes, that's right, because 32 bits is an integer, not a long. Although, frankly speaking, I would modify the hash function for 64-bit version. After all, collision probability is less, and it is easy to adjust for magic expert. However, on the other hand, the current implementation is fully compatible with MQL4 (for it has no long type)
P.S. Wouldn't it be faster, if I convert string to uchar array before loop, and then in loop I have to go through array values one by one? Still, I think calling StringGetCharacter(buf, n) every time in the loop is quite expensive.
I understand that this algorithm can only be 32-bit.
And what about conversion before the loop - how? You would then need an array... dynamic allocation... Yes and there is a loss of information when converting
I understand that this algorithm can only be 32-bit.
3681 ms vs 13822 ms at 3 million runs.... only 4 times different...... but no conversion loss
would be even faster if dat % 256 operation is replaced by dat & 0xFF, and s = (...)%65521; decompose to s = (...); if(s>=65521) s-=65521;
А по поводу конвертации перед циклом - это как? Вам массив тогда понадобится... динамическое распределение... Да и при конвертации происходит потеря информации
So this is the regular conversion before the cycle:
But again, this function is only available in MQL5. The loss of information, as I understand it, occurs in Unicode-->ASCII, which is quite acceptable.
So this is the regular conversion before the cycle:
But again, this function is only available in MQL5. The loss of information, as I understand it, occurs in Unicode-->ASCII, which is quite acceptable.
Well, yes... It's only acceptable for you in your particular task, while not for the algorithm.
Take a closer look at the 64-bit MaHash8v64 (ulong) algorithm, or perhaps both of them together (at least, I will do so for me).
There's no Unicode in MQL4, so there's no problem either.
P.S. StringGetCharacter is pretty fast function, it only returns WORD(ushort for MQL5) from the required position, i.e. it doesn't work with string at all
If anyone has a C++ windows VS application project, preferably for version 10. The project needs to use a dll in its work. I will use it as a template.
Preferably the dll should be called MLP2HL.dll.
Thanks in advance.
If anyone has a C++ windows VS application project, preferably for version 10. The project needs to use a dll in its work. I will use it as a template.
Preferably the dll should be called MLP2HL.dll.
Thank you in advance.
Template is here: ...MetaTrader 4\experts\samples\DLLSample
VS 2010 will convert it automatically. The name can be changed.The template is here: ...MetaTrader 4\experts\samples\DLLSample
VS 2010 converts it automatically. The name can be changed.Nah, I know about the dll template. :)
I need an exe project template which project contains in it the sources of dll, so that I could debug it. A dll is not executable and must be called by someone. I decided to study Intel Parallel Studio 2011 for VS.