Mercado cerrado - página 5

 

Queridos desarrolladores

TE EXIJO que leas este mensaje con atención.

¡¡¡Creo que he descubierto la razón por la que aparece la discrepancia horaria!!!

Hoy:

Terminal

23:49:58.148    Trades  'xxxxx': buy limit 2.00 UCHF-3.18 at 0.9310
23:49:58.154    Trades  'xxxxx': accepted buy limit 2.00 UCHF-3.18 at 0.9310
23:49:58.156    Trades  'xxxxx': buy limit 2.00 UCHF-3.18 at 0.9310 placed for execution in 8.040 ms

Experto

2017.09.21 23:49:58.182 trader (UCHF-3.18,H1)     StopTrading: Время сервера = 23:50:00; Статус ордера = BUY_ORDER; Билет = 77833993  Buy ордер отклонён.
2017.09.21 23:49:58.182 trader (UCHF-3.18,H1)     Alert: Эксперт остановлен. Инструмент UCHF-3.18
2017.09.21 23:49:58.182 trader (UCHF-3.18,H1)     OnTradeTransaction: Buy ордер отклонён брокером(биржей). Билет = 77833993 Причина: 0 0

Mecanismo de control de tiempo.

Cuando la Profundidadde Mercado cambia para un símbolo(yo trabajo sólo con la Profundidad de Mercado)

//+------------------------------------------------------------------+
// Expert Book event function                                        |
//+------------------------------------------------------------------+  
void OnBookEvent(const string &symbol)
{
  if(symbol == Symbol()))
  {
    if(CheckMarketTime(symbol)
    {
      //Выставление ордеров и т.д.
    }
  }     
}

La funciónCheckMarketTime se llama

//+------------------------------------------------------------------+
//| Expert Check Market Time function                                |
//+------------------------------------------------------------------+
bool CheckMarketTime(const string a_symbol)
{
  if(SymbolInfoTick(a_symbol, cur_tick))
  {
    sv_time.year = 0;
    TimeToStruct(cur_tick.time, sv_time);
    if(sv_time.year > 0)
    {
      if((sv_time.day_of_week == int(FirstDay)) ||
         (sv_time.day_of_week == int(SecondDay))) return(false);
      tts_time.year = 0;
      TimeTradeServer(tts_time);
      if(tts_time.year > 0)
      {   
        if((tts_time.day_of_week == sv_time.day_of_week) &&
           (tts_time.hour == sv_time.hour) &&
           (tts_time.min == sv_time.min))
        {
          ulong cur_time = sv_time.hour * 3600 + sv_time.min * 60 + sv_time.sec;
          if(((cur_time >= time_st_mon) && (cur_time < 50370)) ||
             ((cur_time >= time_st_day) && (cur_time < 67470)) ||
             ((cur_time >= time_st_evn) && (cur_time < 85770)))
          {
            return(true);
          }
        }
      }
    }
  }
  return(false);
}

Tras obtener los datos del último tick del símbolo

if(SymbolInfoTick(a_symbol, cur_tick))

¡¡¡¡Compruebo el plazo, pero(MUY IMPORTANTE) !!!!

MqlTick (INMEDIATAMENTE) no contiene el último marco temporal, si

en la profundidad del mercado ha cambiado SÓLO el volumen del mismo precio.

Hago esta suposición porque no hay

Banderas TICK_FLAG_ASK_VOLUMEy TICK_FLAG_BID_VOLUME

La función OnBookEvent ha funcionado (el volumen de tal o cual precio ha cambiado), pero

MqlTick no registró la hora de este cambio.

Por favor, añada estas banderas a MqlTick, respectivamente con el tiempo actualizado.

Añadido

Por alguna razón no puedo hacer un registro en el CD

 
prostotrader:

MqlTick (AQUÍ) no registra la última hora si

en la copa de precios SÓLO ha cambiado el volumen del mismo precio.

Absolutamente correcto. Y este es un comportamiento correcto. MqlTick toma los datos de la misma fuente de la que se llena el historial de ticks. No debería haber duplicados en el historial de ticks, porque el historial de ticks en MT5 no almacena el volumen ni siquiera en las mejores bandas.

Hace tiempo que se ha planteado que no hay una forma directa de conocer el tiempo al que corresponde el historial de garrapatas. Averígualo de otra manera.

 
fxsaber:

Absolutamente correcto. Y este es el comportamiento correcto. MqlTick toma los datos de la misma fuente de la que se llena el historial de ticks. No debería haber duplicados en el historial de ticks, porque el historial de ticks en MT5 no almacena el volumen ni siquiera en las mejores bandas.

Hace tiempo que se ha planteado que no hay una forma directa de conocer el tiempo al que corresponde el historial de garrapatas. Averígualo de otra manera.


¿Sería tan amable de sugerir cuál?

Añadido

Si recibía una notificación de que algo había cambiado en el takan, entonces

por qué no añadir un campo por comodidad ("poca sangre")

datetime book_change; ?

O incluso más sencillo, añadir el siguiente campo a MqlBookInfo

datetime book_change;

Sobre todo porque este tiempo se traduce por el intercambio.

 
prostotrader:

¿Sería tan amable de decirme cuál es?

// Время последнего тика символа
long GetSymbolTime( const string Symb )
{
  MqlTick Tick;
  
  return(SymbolInfoTick(Symb, Tick) ? Tick.time_msc : 0);
}

// Время последнего тика Обзора рынка
long GetMarketWatchTime( void )
{
  long Res = 0;
  
  for (int i = SymbolsTotal(true) - 1; i >= 0; i--)
  {
    const long TmpTime = GetSymbolTime(SymbolName(i, true));
    
    if (TmpTime > Res)
      Res = TmpTime;
  }
  
  return(Res);
}

// Текущее время на торговом сервере без учета пинга
long GetCurrenTime( void )
{
  static ulong StartTime = GetMicrosecondCount();
  static long PrevTime = 0;
  
  const long TmpTime = GetMarketWatchTime();
  
  if (TmpTime > PrevTime)
  {
    PrevTime = TmpTime;
    
    StartTime = GetMicrosecondCount();
  }
  
  return(PrevTime + (long)((GetMicrosecondCount() - StartTime) / 1000));
}

void OnInit()
{
  MarketBookAdd(_Symbol);
}

void OnDeinit( const int )
{
  MarketBookRelease(_Symbol);
}

string TimeToString( const long Value )
{
  return((string)(datetime)(Value / 1000) + "." + (string)IntegerToString(Value % 1000, 3, '0'));
}

void OnBookEvent( const string& )
{
  Comment(TimeToString(GetCurrenTime()));
}
 
fxsaber:

No seas ridículo... :)

 
prostotrader:

Si me han notificado que algo ha cambiado en takan, entonces

por qué no añadir un campo para lo conveniente ("poco dinero")

datetime book_change; ?

O simplemente, añadir la estructura MqlBookInfo con el

datetime book_change;

Especialmente, que este tiempo es traducido por el intercambiador.

Sólo que no es una fecha, sino un tiempo - milisegundos. Y

Foro sobre comercio, sistemas de comercio automatizados y pruebas de estrategias

Mercado cerrado

fxsaber, 2017.09.22 09:17

Hace tiempo quese plantea la cuestión de que no hay una forma directa de saber a qué hora corresponde la ventana de apuestas.

Con sugerencias similares.

 

Quizá después de que se active el OnBookEvent

solicitar CopyTicks en este personaje?

Lo intentaré...

 
prostotrader:

Quizá después de que se active el OnBookEvent

solicitar CopyTicks en este personaje?

No ayudaría, por supuesto. La única opción ahora es averiguar el tiempo del led de la secadora.

 
fxsaber:

No servirá de nada, por supuesto. La única opción ahora es averiguar el momento en que se produce el led del cristal.


Es interesante :)

#property copyright "Copyright 2017 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
//
MqlTick a_ticks[], b_ticks;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(!MarketBookAdd(Symbol()))
   {
     Print("Book not added!");
     return(INIT_FAILED);
   }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
    MarketBookRelease(Symbol());   
  }
//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
  {
    if(symbol == Symbol())
    {
      int res = CopyTicks(symbol, a_ticks, COPY_TICKS_ALL, 0, 1);
      if(res > 0)
      {
        if(SymbolInfoTick(symbol, b_ticks))
        {
          Print("CopyTicks time = ", TimeToString(a_ticks[0].time, TIME_SECONDS), "; SymbolInfoTick = ", TimeToString(b_ticks.time, TIME_SECONDS));
        }
      }
    }
  }

Resultado

2017.09.22 11:18:36.029 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:27; SymbolInfoTick = 11:18:35
2017.09.22 11:18:36.933 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:27; SymbolInfoTick = 11:18:35
2017.09.22 11:18:37.577 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:27; SymbolInfoTick = 11:18:37
2017.09.22 11:18:38.257 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:27; SymbolInfoTick = 11:18:37
2017.09.22 11:18:38.317 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:38; SymbolInfoTick = 11:18:38
2017.09.22 11:18:38.511 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:38; SymbolInfoTick = 11:18:38
2017.09.22 11:18:38.871 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:38; SymbolInfoTick = 11:18:38
2017.09.22 11:18:39.071 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:38; SymbolInfoTick = 11:18:38
2017.09.22 11:18:39.545 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:38; SymbolInfoTick = 11:18:38
2017.09.22 11:18:39.655 Test_time (RTS-12.17,M1)        CopyTicks time = 11:18:38; SymbolInfoTick = 11:18:39

???????

No sé ni qué decir....

 
prostotrader:

No sé ni qué decir....

void OnInit()
{
  MarketBookAdd(_Symbol);
}

void OnDeinit( const int )
{
  MarketBookRelease(_Symbol);
}

string GetTickFlag( uint tickflag )
{
  string flag = "";

#define  TICKFLAG_MACRO(A) flag += ((bool)(tickflag & TICK_FLAG_##A)) ? " TICK_FLAG_" + #A : "";
  TICKFLAG_MACRO(BID)
  TICKFLAG_MACRO(ASK)
  TICKFLAG_MACRO(LAST)
  TICKFLAG_MACRO(VOLUME)
  TICKFLAG_MACRO(BUY)
  TICKFLAG_MACRO(SELL)
#undef  TICKFLAG_MACRO

  if (flag == "")
    flag = " FLAG_UNKNOWN (" + (string)tickflag + ")";
     
  return(flag);
}

#define  TOSTRING(A) " " + #A + " = " + (string)Tick.A

string TickToString( const MqlTick &Tick )
{
  return(TOSTRING(time) + "." + (string)IntegerToString(Tick.time_msc % 1000, 3, '0') +
         TOSTRING(bid) + TOSTRING(ask) + TOSTRING(last)+ TOSTRING(volume) + GetTickFlag(Tick.flags));
}

void OnBookEvent( const string &Symb )
{
  if (Symb == _Symbol)
  {
    MqlTick Tick1, Tick2[];
    
    if (SymbolInfoTick(_Symbol, Tick1) && (CopyTicks(_Symbol, Tick2, COPY_TICKS_ALL, 0, 1) > 0))
      Print("\nMqlTick: " + TickToString(Tick1) + "\nCopyTick: " + TickToString(Tick2[0]));
  }
}

verá que el tiempo sólo será diferente en estas situaciones

Test3 (RTS-12.17,M1)    MqlTick:  time = 2017.09.22 11:21:50.668 bid = 112000.0 ask = 112010.0 last = 112000.0 volume = 5 FLAG_UNKNOWN (0)
Test3 (RTS-12.17,M1)    CopyTick:  time = 2017.09.22 11:21:50.572 bid = 112000.0 ask = 112010.0 last = 112000.0 volume = 5 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_SELL


Se ha discutido varias veces que MqlTick no devuelve un tick tal cual. Que hay dos flujos de ticks - cotización y transacción. Y que en CopyTicks se fusionan a veces de forma retroactiva, porque los flujos no están sincronizados. Y que los tiempos de MqlTick y CopyTicks pueden no coincidir.

Razón de la queja: