Discussão do artigo "Distribuições estatísticas no MQL5 - tirando o melhor de R" - página 14

 

Fórum sobre negociação, sistemas de negociação automatizados e teste de estratégias de negociação

Ajuda com correlação

Quantum, 2016.12.01 12:53 pm.

O arquivo Math.mqh deve ser colocado na pasta terminal_data_folder\MQL5\Include\Math\Stat\.

Ele não é compilado no MT4. #property strict não ajuda

'Math.mqh'      Math.mqh        1       1
'MathLog1p' - no one of the overloads can be applied to the function call       Math.mqh        4655    17
'MathLog1p' - no one of the overloads can be applied to the function call       Math.mqh        4676    16
'MathExpm1' - no one of the overloads can be applied to the function call       Math.mqh        4702    17
'MathExpm1' - no one of the overloads can be applied to the function call       Math.mqh        4723    16
'MathSinh' - no one of the overloads can be applied to the function call        Math.mqh        4750    17
'MathSinh' - no one of the overloads can be applied to the function call        Math.mqh        4772    16
'MathCosh' - no one of the overloads can be applied to the function call        Math.mqh        4799    17
'MathCosh' - no one of the overloads can be applied to the function call        Math.mqh        4821    16
'MathTanh' - no one of the overloads can be applied to the function call        Math.mqh        4848    17
'MathTanh' - no one of the overloads can be applied to the function call        Math.mqh        4870    16
'MathArcsinh' - no one of the overloads can be applied to the function call     Math.mqh        4897    17
'MathArcsinh' - no one of the overloads can be applied to the function call     Math.mqh        4919    16
'MathArccosh' - no one of the overloads can be applied to the function call     Math.mqh        4946    17
'MathArccosh' - no one of the overloads can be applied to the function call     Math.mqh        4968    16
'MathArctanh' - no one of the overloads can be applied to the function call     Math.mqh        4995    17
'MathArctanh' - no one of the overloads can be applied to the function call     Math.mqh        5017    16
16 error(s), 0 warning(s)               17      1
Bug na MQL4?
 
Pergunta para o desenvolvedor: por que as funções matemáticas (no arquivo Math.mqh) não estão agrupadas em uma classe? Talvez elas funcionem mais rápido dessa forma?
 

Esta é uma biblioteca MQL5 sem suporte para MQL4.

As classes não são necessárias nessa biblioteca de matriz.

 
Renat Fatkhullin:

Esta é uma biblioteca MQL5 sem suporte a MQL4.

Mas ela funciona 99% em MQL4, assim como o GraphPlot. Seria 100% se eles corrigissem o erro no MQL4 - nenhuma das sobrecargas pode ser aplicada à chamada de função.
 
O tópico sobre MQL4 e MT4 está encerrado. Não haverá movimentos ou melhorias nesse tópico.
 
fxsaber:
Mas ele funciona 99% em MQL4, assim como o GraphPlot. Seria 100% se eles corrigissem o erro no MQL4 - nenhuma das sobrecargas pode ser aplicada à chamada de função.

Eu olhei com cuidado, mas isso não é um erro do MQL4, mas um erro do MQL5!

//+------------------------------------------------------------------+
//| MathLog1p|
//+------------------------------------------------------------------+
//| A função calcula log(1+x) para os elementos da matriz.
//||
//| Argumentos:|
//| matriz[] : Matriz com valores|
//| result[] : Matriz de saída com valores calculados
//||
//| Valor de retorno: verdadeiro se for bem-sucedido, caso contrário, falso
//+------------------------------------------------------------------+
bool MathLog1p(const double &array[],double &result[])
  {
   int size=ArraySize(array);
   if(size==0)
      return(false);
//--- preparar a matriz de destino
   if(ArraySize(result)<size)
      if(ArrayResize(result,size)!=size)
         return(false);
//--- calcular valores
   for(int i=0; i<size; i++)
      result[i]=MathLog1p(array[i]);
//---
   return(true);
  }
//+------------------------------------------------------------------+
//| MathLog1p|
//+------------------------------------------------------------------+
//| A função calcula log(1+x) para os elementos da matriz.
//||
//| Argumentos:|
//| matriz[] : Matriz com valores|
//||
//| Valor de retorno: verdadeiro se for bem-sucedido, caso contrário, falso
//+------------------------------------------------------------------+
bool MathLog1p(double &array[])
  {
   int size=ArraySize(array);
   if(size==0)
      return(false);
//--- calcular valores
   for(int i=0; i<size; i++)
      array[i]=MathLog1p(array[i]);
//---
   return(true);
  }

A MQL4 fala corretamente - nenhuma das sobrecargas pode ser aplicada à chamada defunção. Mas o MQL5 fica em silêncio quando há um erro óbvio. @Renat Fatkhullin, um bug?

 
fxsaber:
A MQL4 avisa corretamente - nenhuma das sobrecargas pode ser aplicada à chamada defunção. E a MQL5 é silenciosa quando há um erro óbvio.

Isso não é um erro. A MQL5 tem essas funções.


 
Quantum:

Isso não é um erro. A MQL5 tem essas funções.

Obrigado! E eu, como um tolo, pressiono ALT+G....
 

Olá,
encontrei um problema ao calcular o quantil da distribuição gama
em R:
> qgamma(0.05,2,scale=1)
[1] 0.3553615
> qgamma(0.05,10,scale=1)
[1] 5.425406

em mql5:

#include <Math\Stat\Gamma.mqh>
void OnStart()
  {
   int ner;
   double q=MathQuantileGamma(0.05,2,1,ner);
   if(!MathIsValidNumber(q)) {Print("Error ",ner); return;}
   Print(q);
   q=MathQuantileGamma(0.05,10,1,ner);
   if(!MathIsValidNumber(q)) {Print("Error ",ner); return;}
   Print(q);
  }

Resultados:
0.3553615106986621
Erro 4

build 1596

 
Alexey Nikolaev:

Olá,
encontrou um problema ao calcular o quantil da distribuição gama

Boa tarde, obrigado por sua mensagem.

O erro 4 significa problemas de convergência no algoritmo de iteração inversa de Newton, que é usado para encontrar os quantis. Daremos uma olhada no problema.