Probando 'CopyTicks' - página 14

 
Rashid Umarov:

Por ejemplo

Ligeramente revisado

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";
     
  return(flag);
}

Resultado

2016.09.14 13:52:33.925 Test (Si-9.16,M1)       Tick23: time = 2016.09.13 18:52:35.505 bid = 0.0 ask = 0.0 last = 65253.0 volume = 35  TICK_FLAG_BID TICK_FLAG_ASK

Resulta que ambos precios cambian a cero a partir de valores no nulos. Y después de los ceros volver a los no ceros.

 
fxsaber:

El indicador muestra que CopyTicks puede no estar regalando los últimos ticks

Aún más interesante

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 )
{
  static int i = 0;
  
  i++;
  
  return("Tick" + (string)i + ":" + TOSTRING(time) + "." + (string)(Tick.time_msc %1000) +
         TOSTRING(bid) + TOSTRING(ask) + TOSTRING(last)+ TOSTRING(volume) + GetTickFlag(Tick.flags));
}

bool MySymbolInfoTick( const string Symb, MqlTick &Tick, const uint Type = COPY_TICKS_ALL )
{
  MqlTick Ticks[];
  const int Amount = ::CopyTicks(Symb, Ticks, Type, 0, 1);
  const bool Res = (Amount > 0);
  
  if (Res)
    Tick = Ticks[Amount - 1];
  
  return(Res);
}

#define  INDICATOR // Переключение между индикатором и экспертом

#ifdef  INDICATOR
  #define  NAME "Indicator: "

  #property indicator_chart_window
  #property indicator_buffers 0
  #property indicator_plots   0

  int OnCalculate( const int rates_total,
                   const int prev_calculated,
                   const datetime &time[],
                   const double &open[],
                   const double &high[],
                   const double &low[],
                   const double &close[],
                   const long &tick_volume[],
                   const long &volume[],
                   const int &spread[] )
#else
  #define  NAME "Expert: "

  void OnTick( void )
#endif
{
  MqlTick Tick1, Tick2;
  
  if (SymbolInfoTick(_Symbol, Tick1) && MySymbolInfoTick(_Symbol, Tick2))
    if (Tick1.time_msc != Tick2.time_msc)
      Print(NAME + ((Tick1.time_msc > Tick2.time_msc) ? "EventTime > CopyTicks_Time" : "EventTime < CopyTicks_Time") +
            "\nFrom Event: " + TickToString(Tick1) + "\nFrom CopyTicks: " + TickToString(Tick2) + "\n");

#ifdef  INDICATOR 
  return(rates_total);
#endif
}
Resultado
2016.09.14 14:25:24.533 Test2 (Si-9.16,M1)      From CopyTicks: Tick16: time = 2016.09.14 14:25:06.62 bid = 65013.0 ask = 65015.0 last = 65014.0 volume = 1 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_SELL
2016.09.14 14:25:24.533 Test2 (Si-9.16,M1)      From Event: Tick15: time = 2016.09.14 14:25:06.68 bid = 65013.0 ask = 65015.0 last = 65014.0 volume = 1 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_SELL
2016.09.14 14:25:24.533 Test2 (Si-9.16,M1)      Indicator: EventTime > CopyTicks_Time
2016.09.14 14:25:24.533 Test2 (Si-9.16,M1)      
2016.09.14 14:25:24.533 Test2 (Si-9.16,M1)      From CopyTicks: Tick14: time = 2016.09.14 14:25:06.62 bid = 65013.0 ask = 65015.0 last = 65014.0 volume = 1 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_SELL
2016.09.14 14:25:24.533 Test2 (Si-9.16,M1)      From Event: Tick13: time = 2016.09.14 14:25:06.68 bid = 65013.0 ask = 65015.0 last = 65014.0 volume = 1 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_SELL
2016.09.14 14:25:24.533 Test2 (Si-9.16,M1)      Indicator: EventTime > CopyTicks_Time
2016.09.14 14:25:18.974 Test2 (Si-9.16,M1)      
2016.09.14 14:25:18.974 Test2 (Si-9.16,M1)      From CopyTicks: Tick12: time = 2016.09.14 14:25:00.519 bid = 65011.0 ask = 65012.0 last = 65012.0 volume = 8 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_BUY
2016.09.14 14:25:18.974 Test2 (Si-9.16,M1)      From Event: Tick11: time = 2016.09.14 14:25:00.510 bid = 65011.0 ask = 65012.0 last = 65012.0 volume = 8 FLAG_UNKNOWN (0)
2016.09.14 14:25:18.974 Test2 (Si-9.16,M1)      Indicator: EventTime < CopyTicks_Time

Los CopyTicks pueden ir tanto por detrás como por delante del Event-tick. El evento-tick a menudo tiene una bandera cero.

ZZY Corregir la bandera MqlTick a las banderas en la ayuda MqlTick.

 

No entiendo cómo los demás utilizan CopyTicks. No hay confianza, por desgracia. Muy crudo.

EA

#include <TypeToBytes.mqh> // https://www.mql5.com/ru/code/16280

void OnTick( void )
{
  static MqlTick PrevTick;  
  static int Amount = 0;
  
  MqlTick Ticks[];
  
  if (Amount > 0)
  {
    Amount = CopyTicks(_Symbol, Ticks, COPY_TICKS_ALL, PrevTick.time_msc);
    
    int i;
    
    for (i = 0; i < Amount; i++)
      if (_R(Ticks[i]) == PrevTick) // https://www.mql5.com/ru/code/16280
        break;
        
    if (i == Amount)
      Print("В истории (length = " + (string)Amount + ") нет тика, что был на предыдущем Event.");
  }
  else
    Amount = CopyTicks(_Symbol, Ticks, COPY_TICKS_ALL, TimeCurrent() * 1000);
    
  if (Amount > 0)
    PrevTick = Ticks[Amount - 1];  
}

Resultado

2016.09.15 11:04:02.810 Test2 (RTS-9.16,M1)     В истории (length = 2) нет тика, что был на предыдущем Event.
2016.09.15 11:03:59.312 Test2 (RTS-9.16,M1)     В истории (length = 13) нет тика, что был на предыдущем Event.
2016.09.15 11:03:59.290 Test2 (RTS-9.16,M1)     В истории (length = 1) нет тика, что был на предыдущем Event.

La garrapata que estaba en el historial ya está ausente en el siguiente evento de garrapatas.

Estimados desarrolladores, hagan que CopyTicks funcione. Incluso las pruebas más sencillas fallan.

 
Por el momento CopyTicks con un poco de estiramiento, pero funciona en tiempo real con el parámetro de entrada de == 0.
 

Necesito añadir nuevos ticks del historial al array en cada OnTick. ¿Alguien lo ha puesto en práctica?

Estoy luchando - no está funcionando. No consigo evitar la curvatura de CopyTicks.

 
fxsaber:
Por el momento CopyTicks con un poco de estiramiento, pero funciona en tiempo real con el parámetro de entrada de == 0.
Este es uno de los tramos
void OnTick( void )
{
  MqlTick Ticks[];
  
  const int Amount = CopyTicks(_Symbol, Ticks);
  
  if ((Amount > 1) && (Ticks[Amount - 1].time_msc < Ticks[Amount - 2].time_msc))
    Print("Некорректная история!");
}
Resultado
2016.09.15 13:11:13.231 Test4 (RTS-9.16,M1)     Некорректная история!
2016.09.15 13:10:48.954 Test4 (RTS-9.16,M1)     Некорректная история!
Tomamos los ticks del borde, y encontramos que el tick más reciente tiene menos tiempo que el anterior.
 
fxsaber:
Aquí está uno de los tramosRecibe los ticks extremos, y encuentra que el tick más reciente tiene un tiempo más corto que el anterior.

Compruebe el código de este indicador

https://www.mql5.com/ru/forum/94399/page6#comment_2776784

Таблица всех сделок. Доступ через MQL5
Таблица всех сделок. Доступ через MQL5
  • comentarios: 1
  • www.mql5.com
Как организовать получение таблицы сделок? Пока не важно из индикатора или из советника...
 
fxsaber:
Tomamos los ticks extremos, y encontramos que el tick más reciente tiene un tiempo más corto que el anterior.
Esto se aplica sólo a COPY_TICKS_ALL. Con los otros modos, el EA sugerido no ha detectado ningún error.
 
¿Tengo que escribir al Servicio de Atención al Cliente sobre los informes de este hilo o los desarrolladores lo supervisan ellos mismos?
 
fxsaber:
¿Tengo que escribir al Servicio de Atención al Cliente sobre los informes de este hilo o los desarrolladores lo supervisan ellos mismos?
Será mejor que les escribas. No será superfluo.