Get the number of decimal places of any numbers (not just quotes) bypassing Digits() in MQL4 and MQL5 - page 18

 
Dmitry Fedoseev:

Apparently, but don't despair, all is not lost, I believe in you.

So what's this here for? Go on, please.

 
fxsaber:

Without going beyond the MQL.

#import "msvcrt.dll"
  long memcpy(MqlTick &dst[], int &src[], uint cnt);
  long memcpy(int &dst[], MqlTick &src[], uint cnt);
#import

int TicksToIntArray_thexpert( MqlTick &Ticks[], int &Array[] )
{
  const int Size1 = ArraySize(Ticks);
  const int Size2 = ArrayResize(Array, Size1 * sizeof(MqlTick) / sizeof(int));

  memcpy(Array, Ticks, Size2 * sizeof(int));
  
  return Size2;
}

// Перевод массива int[] в массив тиков.
int IntArrayToTicks_thexpert( int &Array[], MqlTick &Ticks[] )
{
  const int Size1 = ArraySize(Array);
  const int Size2 = ArrayResize(Ticks, Size1 * sizeof(int) / sizeof(MqlTick));

  memcpy(Ticks, Array, Size2 * sizeof(MqlTick));
  
  return Size2;
}

Time[TicksToIntArray_fxsaber2(TicksIn,Array)] = 140528
Time[IntArrayToTicks_fxsaber2(Array,TicksOut)] = 159885
true
Time[TicksToIntArray_thexpert(TicksIn,Array2)] = 58099
Time[IntArrayToTicks_thexpert(Array2,TicksOut2)] = 65944
true
 
TheXpert:

Thanks, so far so good.

https://www.mql5.com/ru/forum/287618/page18#comment_9813963
TicksToIntArray_thexpert
Time[TicksToIntArray(TicksIn,Array)] = 80994
IntArrayToTicks_thexpert
Time[IntArrayToTicks(Array,TicksOut)] = 80410
true

https://www.mql5.com/ru/forum/287618/page18#comment_9814108
TicksToIntArray_fxsaber4
Time[TicksToIntArray(TicksIn,Array)] = 102718
IntArrayToTicks_fxsaber4
Time[IntArrayToTicks(Array,TicksOut)] = 103835
true


The DLL variant is 20% faster than the better MQL variant, which probably can't be accelerated any more (not a simple one came out).

Files:
 
I personally would not use dlls, even for the sake of a 20% gain, as it reduces security at least, increases complexity of use and looks ambiguous. When using someone else's software, it's better to disable dll calls altogether...
 

fxsaber:

The DLL variant is 20% faster than the better MQL variant, which probably can't be accelerated any more (not a simple one).

Your code may be sped up if you increase array size from 128 to 10000.

Ilya Malev:
I personally wouldn't use any dlls, even for the sake of 20% speedup, because it decreases the security at least, increases the complexity of use and looks ambiguous. When using someone else's software it's better to disable dll calls altogether...

I posted an example more to see how much more efficient bare-memory work is compared to native implementations. And for me 20% lag of native code is a very, very good result.

but yes -- less security and everything else. But if you want speed and want it for yourself, you can)

 
TheXpert:

It's essentially a single low-level system function call. Your code can be accelerated by increasing the array size from 128 to 10000.

Tried different sizes, of course. For some reason, they don't affect the result.

 
fxsaber:

I need it for the HistoryTicks library. Thanks for participating.

By the way, do you have something in your libraries to transfer owls from MT4 to MT5 without changing trading functions for identical MT4 work with orders and order history? Please send me the link if you have it.

 
Ilya Malev:

By the way, do you have one in your libraries to transfer owls from MT4 to MT5 without changing trading functions for identical MT4 work with orders and order history? If you have such a library, please send me the link.

I have all libraries in my profile in the Publications section.

 
fxsaber:

In my profile, under Publications, all the libraries are lying around.

I understand. I was hoping to get an insider's answer, how fully it is implemented and a link, so I don't have to look there myself. Anyway, it doesn't matter, I'll write it myself anyway, because I like other people's ideas and not so much other people's code :)

 
Ilya Malev:

I understand. I was hoping to get an insider's answer, how fully it is implemented and a link, so I don't have to look there myself. Anyway, it doesn't matter, I'll write it myself anyway, as I like other people's ideas and not so much other people's code :)

https://www.mql5.com/ru/code/16006


Total identity. When I started writing it, I had no idea of the number of pitfalls I'd have to avoid. I wouldn't have tried it again.

MT4Orders
MT4Orders
  • www.mql5.com
Данная библиотека позволяет работать с ордерами в MQL5 (MT5-hedge) точно так же, как в MQL4. Т.е. ордерная языковая система (ОЯС) становится идентичной MQL4. При этом сохраняется возможность параллельно использовать MQL5-ордерную систему. В частности, стандартная MQL5-библиотека будет продолжать полноценно работать. Выбор между ордерными...
Reason: