Synchronisierung der Windows-Ortszeit mit dem MT5-Server - Seite 3

 
fxsaber:
Auch der Ping sollte halbiert werden - man muss nicht hin und her gehen, sondern nur zurück.

Und wenn MQs nur hier zählen?

Hinzugefügt von

Korrigiert

Hinzugefügt

Damit der EA sicherer arbeiten kann

In Market Watch sollten Sie aktuelle hochliquide

Termingeschäfte wie RTS, Si, BR

Dateien:
 

Wir müssen noch die Synchronisierung des abendlichen Clearings hinzufügen.

Hinzugefügt

Auch zur Lichtung gemacht

Dateien:
 

Es gab eine Korrektur bei der Verrechnung (real)

2017.01.18 18:56:11.852 Time_sync_forts (URKA-3.17,H1)  Local time sync is done.


Aber das Ergebnis hat mir überhaupt nicht gefallen,

lag 49 Sekunden zurück :(

Ich werde morgen die vorbörslichen Daten prüfen....

 
Mikalas, du bist mein Idol! :-)
 
Dennis Kirichenko:
Mikalas, du bist mein Idol! :-)
Mein Herr! Was wollen Sie?
 

Hier ist das Problem.

Print("Local time sync is done. Symbol = ", symbol, " Sync min = ", loc_time.wMinute,
                           " Sync sec = ", loc_time.wSecond, " Sync mcs = ", loc_time.wMilliseconds);

2017.01.18 20:05:01.743 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 428
2017.01.18 20:05:01.869 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:01.890 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 61
2017.01.18 20:05:01.918 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 61
2017.01.18 20:05:01.942 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 428
2017.01.18 20:05:01.942 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:01.983 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.055 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 61
2017.01.18 20:05:02.081 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.081 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:02.121 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.216 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 385
2017.01.18 20:05:02.242 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 385
2017.01.18 20:05:02.255 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.255 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:02.314 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:02.405 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:02.432 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.432 Time_sync_forts (RTS-3.17,M1)   Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 614
 

Die vorherige Krücke war viel schlanker (durch Design), aber,

Ich werde das ausprobieren.

//+------------------------------------------------------------------+
//|                                              Time_sync_forts.mq5 |
//|                                      Copyright 2017 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
//---
struct _SYSTEMTIME
  {
   ushort            wYear;
   ushort            wMonth;
   ushort            wDayOfWeek;
   ushort            wDay;
   ushort            wHour;
   ushort            wMinute;
   ushort            wSecond;
   ushort            wMilliseconds;
  };

_SYSTEMTIME loc_time;

#import "kernel32.dll"
void GetLocalTime(_SYSTEMTIME &sys_time);
bool SetLocalTime(_SYSTEMTIME &sys_time);
#import
//---
bool     is_sync;
string   symb_rts;
string   symb_si;
string   symb_gold;
string   symb_br;
string   symb_gazr;
string   symb_sbrf;
datetime last_time;
//
input string BrInstr="BR-2.17"; //Brent
//+------------------------------------------------------------------+
//| Expert set second symbol function                                |
//+------------------------------------------------------------------+
string SetSecSymbol(const string a_symbol,const string prefix)
  {
   int str_tire=0;
   ushort let_symbol;
   int str_size=StringLen(a_symbol);

   for(int i=0; i<str_size; i++)
     {
      let_symbol=StringGetCharacter(a_symbol,i);

      if(let_symbol=='-')
        {
         str_tire=i;
         break;
        }
     }
   if(str_tire>0)
     {
      return(prefix + StringSubstr(a_symbol, str_tire, str_size - str_tire));
     }
   return("");
  }
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   last_time=TimeCurrent();
   is_sync=false;
   MarketBookAdd(Symbol());
//---  
   symb_rts=SetSecSymbol(Symbol(),"RTS");
   if(!SymbolSelect(symb_rts,true))
     {
      MessageBox(symb_rts+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_rts);
//---  
   symb_si=SetSecSymbol(Symbol(),"Si");
   if(!SymbolSelect(symb_si,true))
     {
      MessageBox(symb_si+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_si);
//---
   symb_gold=SetSecSymbol(Symbol(),"GOLD");
   if(!SymbolSelect(symb_gold,true))
     {
      MessageBox(symb_gold+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_gold);
//---
   symb_gazr=SetSecSymbol(Symbol(),"GAZR");
   if(!SymbolSelect(symb_gazr,true))
     {
      MessageBox(symb_gazr+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_gazr);
//---
   symb_sbrf=SetSecSymbol(Symbol(),"SBRF");
   if(!SymbolSelect(symb_sbrf,true))
     {
      MessageBox(symb_sbrf+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_sbrf);
//---
   symb_br=BrInstr;
   if(!SymbolSelect(symb_br,true))
     {
      MessageBox(symb_br+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
      return(INIT_FAILED);
     }
   else MarketBookAdd(symb_br);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   MarketBookRelease(Symbol());
   MarketBookRelease(symb_rts);
   MarketBookRelease(symb_br);
   MarketBookRelease(symb_si);
   MarketBookRelease(symb_gold);
   MarketBookRelease(symb_gazr);
   MarketBookRelease(symb_sbrf);
  }
//+------------------------------------------------------------------+
//| Expert On book event function                                    |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
  {
   loc_time.wYear=0;
   GetLocalTime(loc_time);
   if(loc_time.wYear>0)
     {
      if(((loc_time.wHour==9) && (loc_time.wMinute>=50) && (loc_time.wMinute<=59)) ||
         ((loc_time.wHour==14) && (loc_time.wMinute>=0) && (loc_time.wMinute<=4)) ||
         ((loc_time.wHour==18) && (loc_time.wMinute>=45) && (loc_time.wMinute<=59)))
        {
         MqlDateTime sv_time;
         datetime cur_time=TimeCurrent(sv_time);
         if(ulong(cur_time) == ulong(last_time)) return;
         if((loc_time.wDayOfWeek==ushort(sv_time.day_of_week)) &&
            (loc_time.wHour==ushort(sv_time.hour)))
           {
              
               if(!is_sync)
                 {
                  loc_time.wMinute = ushort(sv_time.min);
                  loc_time.wSecond = ushort(sv_time.sec);
                  loc_time.wMilliseconds=0;
                  if(SetLocalTime(loc_time))
                    {
                     is_sync=true;
                     Print("Local time sync is done. Symbol = ",symbol," Sync min = ",loc_time.wMinute,
                           " Sync sec = ",loc_time.wSecond);
                    }
                 }
              
           }
        }
      else
        {
         is_sync=false;
         last_time=TimeCurrent();
        }
     }
  }
//+------------------------------------------------------------------+
 
prostotrader:

Die vorherige Krücke war viel schlanker (durch Design), aber,

Ich werde das ausprobieren.

Dies wird nicht mitOnBookEvent funktionieren, Sie müssen es mit OnTick synchronisieren.

können Sie die Tick-Zeit verwenden und die Daten zum Zeitpunkt des Glaswechsels erfassen,

timeOnBookEvent!=OnTick

 
Sergey Chalyshev:

DasOnBookEvent wird nicht funktionieren, Sie müssen mit OnTick synchronisieren.

Sie können die Tick-Zeit verwenden und die Daten zum Zeitpunkt der Änderung erfassen,

timeOnBookEvent!=OnTick

Nein, Sergej!

Ihr OnTick für das ausgewählte Symbol wird möglicherweise gar nicht ausgelöst, während OnBookEvent() bei jeder Änderung der

Brillen aller ausgewählten Symbole.

 
prostotrader:

Nein, Serge!

OnTick auf dem ausgewählten Symbol kann nicht kommen, aber OnBookEvent() wird bei jeder Änderung von

Gläser für alle ausgewählten Symbole.

OnBookEvent() wird ausgelöst, aber der Zeitpunkt des Becherwechsels ist nirgends festgelegt.

Nur die Ankunftszeit des Tickers ist festgelegt, d.h. die Änderung von Bid, Last, Ask.

Der Marktkurs hat sich also geändert, aber der Zeitpunkt des letzten Ticks ist derselbe wie zuvor.

Grund der Beschwerde: