Libraries: Init_Sync - page 2

 
fxsaber:

I didn't find a dangerous example.

In my memory, this is the only such library where #include is present but nothing from it is called by the user anywhere in the code.

Well, the main thing in this library is a tricky overriding of standard functions. It turns out to be an implicit call.

I'm telling you about the danger from the viewpoint of changes and code support. All these implicit overrides will be easily forgotten, and then, when the platform changes or the synchroniser breaks, it will be very difficult to detect them. But still, I agree that this is a far-fetched situation. In general - the idea is very original and sensible. Indeed, by simply connecting the library, without any calls, we get a very useful result.

 
fxsaber:


By the way, thanks for the code. I learnt a lot of valuable things and got some interesting ideas.
 
Measured the delay time
    static const ulong StartTime = GetMicrosecondCount();    

// if (FirstRun && (!::GlobalVariableCheck(INIT_SYNC::InitSync.GlobalName)))
    if (FirstRun && (!INIT_SYNC::ResourceCheck(INIT_SYNC::InitSync.GlobalName)))
    {
// FirstRun = (::GlobalVariableSet(INIT_SYNC::InitSync.GlobalName, 0) == 0);
      FirstRun = !INIT_SYNC::ResourceCreate(INIT_SYNC::InitSync.GlobalName);

      if (!FirstRun)
      {
        Print(GetMicrosecondCount() - StartTime);

Sometimes it reaches up to 300 ms when switching TF. And this is not on "cold". It turns out that even a "hot" terminal sometimes slows down.

Probably, I should write about it to SD to fix it.

 

Unfortunately, I cannot understand this. No sequence is disturbed in my tests.

DeInit and then Init are executed as expected. Anything else would be rather questionable.


So I wonder what this code example is supposed to do !

 

I suspect that this sometimes occurs, but not always and not necessarily.

It is probably due to the 'threadrace' and it is not possible to determine what is executed when and in what order.

I once had the idea myself (in MT4, but should also work in MT5)

   int lastPing = TerminalInfoInteger(TERMINAL_PING_LAST);

to use an interruption of the connection to the server - not possible!

Since the ping test is executed by the terminal in its own thread, it is not certain that this command, even if it is the very, very, very first in OnCalculate() or OnTick(), will display the undercalculation correctly.

If the ping test was executed just a millisecond before, it shows that everything is ok :(

Try it out by simply pulling the landing cable...

My suggestion, either by changing the threading (probably difficult), or by providing the last 2, 3 ping tests (would be easy) from an EA or indicator to be able to recognise an interruption super easily: We have no intention....

 
Otto Pauser:

Unfortunately, I cannot understand this. No sequence is disturbed in my tests.

DeInit and then Init are executed as expected. Anything else would be rather questionable.


So I wonder what this code example is supposed to do !

If you start this indicator and change its time frame or symbol, you will see a disturbance in the order of the strings "Init" and "Deinit" in the journal.
 

A hodgepodge of another MT5 indicator specificity.


There is a very subtle point in the library source

  static string GetMyUniqueName( void )
  {
    const int handle = GetMyHandle();

    MqlParam Params[];
    ENUM_INDICATOR Type;

    const int Total = ::IndicatorParameters(handle, Type, Params);
    ::IndicatorRelease(handle);

    uchar Bytes[];

    for (int i = 1; i < Total; i++)
    {
      ::ArrayCopy(Bytes, _R(Params[i].double_value).Bytes, ::ArraySize(Bytes));
      ::ArrayCopy(Bytes, _R(Params[i].integer_value).Bytes, ::ArraySize(Bytes));
      ::ArrayCopy(Bytes, _R(Params[i].string_value).Bytes, ::ArraySize(Bytes));
    }

    return("::" + (string)::ChartID() + (string)INIT_SYNC::crc64(Bytes) + ::MQLInfoString(MQL_PROGRAM_NAME));
  }


It is a highlighted line, which is mandatory, but the reason for it is difficult to explain in words.

[Deleted]  

Hello @fxsaber, I'm getting the following errors while trying to use your library


How do I fix this ? thanks.

 
Paul Carissimo:

Hello @fxsaber, I'm getting the following errors while trying to use your library

How do I fix this ? thanks.

Read the description carefully.