Características da linguagem mql5, subtilezas e técnicas - página 196

 
fxsaber:

Nenhuma sugestão sobre de onde vem a hora (o mesmo para mim). Talvez dependa do fuso horário.


Isto já não é interessante.

Sem palpites. Tenho Moscovo. Com GMT não uma hora... Nenhuma outra reflexão.

 

Andrey Khatimlianskii:

Fórum sobre comércio, sistemas automatizados de comércio e testes de estratégia comercial

Como utilizar o controlo automático de erros no terminal?

Renat Fatkhullin, 2021.01.22 16:12

Existe uma forma não documentada de repor à força os registos em disco através da impressão (NULL)

Fixe!

 
Andrey Khatimlianskii:

fxsaber:

Fixe!

Com pressa de partilhar sem verificação.

 
Andrey Khatimlianskii:

Na minha pressa de partilhar sem verificação.


E se a corda for zerada em primeiro lugar e depois impressa
 

Opção para mostrar (não activar) o gráfico (MT5 apenas)

// Показывает (не активирует) данный чарт.
bool ChartShow( const long Chart )
{
  const bool IsDocked = ChartGetInteger(Chart, CHART_IS_DOCKED);
  
  return(ChartSetInteger(Chart, CHART_IS_DOCKED, !IsDocked) && 
         ChartSetInteger(Chart, CHART_IS_DOCKED, IsDocked) &&
         ChartGetInteger(Chart, CHART_WINDOW_HANDLE));  
}


Exemplo de utilização.

// Переключает чарты клавишами клавиатуры '<'/'>'.

#define  KEY_LEFT2 188  // '<'
#define  KEY_RIGHT2 190 // '>'

int GetExpertCharts( long &Charts[], const string ExpertName = NULL )
{
  int Amount = 0;
  
  for (long Chart = ChartFirst(); Chart != -1; Chart = ChartNext(Chart))
    if ((ExpertName == NULL ) || (ChartGetString(Chart, CHART_EXPERT_NAME) == ExpertName))
    {
      Amount = ArrayResize(Charts, Amount + 1, 10);
      
      Charts[Amount - 1] = Chart;
    }
    
  return(ArrayResize(Charts, Amount));
}

long ChartNextShow( const long Chart, const int Step = 1 )
{
  long ResChart = Chart;
  
  long Charts[];  
  const int Size = GetExpertCharts(Charts);
  
  if ((Size > 1) && (bool)(Step % Size))
    for (int i = 0; i < Size; i++)  
      if (Charts[i] == Chart)
      {
        ResChart = Charts[(i + ((Step > 0) ? Step : (Size - ((-Step) % Size)))) % Size];
        
        ChartShow(ResChart); // https://www.mql5.com/ru/forum/170952/page196#comment_20841674
        
        break;
      }

  return(ResChart);  
}

void OnChartEvent( const int id, const long &lparam, const double&, const string& ) 
{         
  static long Chart = ChartID();
  
  if (id == CHARTEVENT_KEYDOWN) 
    switch ((int)lparam)
    {
    case KEY_LEFT2:
      Chart = ChartNextShow(Chart, -1); // Показали чарт слева
      break;

    case KEY_RIGHT2:
      Chart = ChartNextShow(Chart); // Показали чарт справа
      break;
    }
}

Infelizmente, não foi possível encontrar uma opção de activação de gráficos. Apenas visualização.

 
Solução para um problema antigo.
/*
// https://www.mql5.com/ru/forum/1111/page2863#comment_18591240
#define VALUE 10

#define MACROS

#ifdef MACROS
  // Нужно VALUE увеличить в два раза.
#endif
*/

// https://www.mql5.com/ru/forum/1111/page2965#comment_20841725
#define  MACRO(  x, y, z )       enum nn##z { y = x };
#define  MACRO2( x, y )          MACRO( x, y, __LINE__ )

// https://www.mql5.com/ru/forum/1111/page2866#comment_18603128
#define  VALUE 10

MACRO2(VALUE, VALUE_TMP) // VALUE_TMP - поле enum, поэтому имя не должно повторяться.
#undef  VALUE
#define  VALUE (VALUE_TMP * 2)

void OnStart()
{
  Print(VALUE);
}

Esta opção é melhor do que esta.

#define  MACRO3(x, y)            const int y = x;

MACRO3(VALUE, VALUE_TMP)

Não necessita de uma variável. Todos os valores são definidos em tempo de compilação. Obrigado @A100!

 
fxsaber:

Infelizmente, não foi possível encontrar uma opção de activação de gráficos. Apenas a exposição.

Não percebo......... é disso que estás a falar? É um guião.


ps; E o que é isto

  const bool IsDocked = ChartGetInteger(Chart, CHART_IS_DOCKED);

Não consigo encontrá-lo na documentação...

Arquivos anexados:
200.mq5  2 kb
 
Alexey Viktorov:

ps; O que é isto

Não consigo encontrá-lo na documentação...

É ALT+D na tabela.

 
Alexey Viktorov:

Não percebo......... estás a falar disto? É um guião.

Obrigado, algo que eu exagerei. É claro que, acima, ficou a gestão gráfica que não se conseguia antes. Mas o meu objectivo era diferente.

// Активирует данный чарт.
bool ChartActivate( const long Chart )
{
  return(ChartSetInteger(Chart, CHART_BRING_TO_TOP, true) && ChartGetInteger(Chart, CHART_WINDOW_HANDLE));
}


Exemplo de utilização.

// Переключает чарты с одним и тем же советником клавишами клавиатуры '<'/'>'.

void ChartNextActivate( const int Step = 1, const bool Expert = true )
{
  long Charts[];  
  // https://www.mql5.com/ru/forum/170952/page196#comment_20841674
  const int Size = GetExpertCharts(Charts, Expert ? ChartGetString(0, CHART_EXPERT_NAME) : NULL);
  const long Chart = ChartID();
  
  if ((Size > 1) && (bool)(Step % Size))
    for (int i = 0; i < Size; i++)  
      if (Charts[i] == Chart)
      {
        // https://www.mql5.com/ru/forum/170952/page197#comment_20845067
        ChartActivate(Charts[(i + ((Step > 0) ? Step : (Size - ((-Step) % Size)))) % Size]);
        
        break;
      }

  return;  
}

void OnChartEvent( const int id, const long &lparam, const double&, const string& ) 
{         
  if (id == CHARTEVENT_KEYDOWN) 
    switch ((int)lparam)
    {
    case KEY_LEFT2:
      ChartNextActivate(-1);
      break;

    case KEY_RIGHT2:
      ChartNextActivate();      
      break;
    }
}
Razão: