Discussão do artigo "Integração da MetaTrader 5 e Python: recebendo e enviando dados" - página 6

 
Maxim Dmitrievsky:

Hi all

Note

Connection address should be added to the list of allowed ones on the client terminal side (Tools \ Options \ Expert Advisors).

If connection fails, error 5272 (ERR_NETSOCKET_CANNOT_CONNECT) is written to  _LastError.

The function can be called only from Expert Advisors and scripts, as they run in their own execution threads. If calling from an indicator,  GetLastError() returns the error 4014 – "Function is not allowed for call".



https://www.mql5.com/en/docs/network/socketconnect


Hi Maxim Dmitrievsky,

I allowed the localhost and it's working correctly. Thank you very much! But when I ran in backtest using the Strategy Tester, the error 4014 persisted. The socket doesn't work with backtest?

Best regards
[Excluído]  
auuuuu1628:

Hi Maxim Dmitrievsky,

I allowed the localhost and it's working correctly. Thank you very much! But when I ran in backtest using the Strategy Tester, the error 4014 persisted. The socket doesn't work with backtest?

Best regards

Yes, all right. Metaquotes disabled this feature in backtester, but they say maybe allow this in near future.

 

Por que não fechar "xxx" imediatamente após receber uma resposta do servidor, em vez de continuar aguardando a resposta até atingir o TimeOut?

Estou me referindo ao incrível programa desenvolvido por @MaximDmitrievsky -> https://www.mql5.com/pt/articles/5691

(( A função socketreceive() escuta em uma porta e a retorna como uma string quando há uma resposta do servidor: ))

string socketreceive(int sock, int timeout) {
        char rsp[];
        string result = "";
        uint len;
        uint timeout_check=GetTickCount()+timeout;
        do {
                len=SocketIsReadable(sock); 
                if(len){
                        int rsp_len;
                        rsp_len = SocketRead(sock,rsp,len,timeout);
                        if(rsp_len>0){
                                result+=CharArrayToString(rsp,0,rsp_len); 
                        }
                }
        } while((GetTickCount()<timeout_check) && !IsStopped());
        return result;
}

Parabéns por esse excelente artigo.

Maxim Dmitrievsky
Maxim Dmitrievsky
  • www.mql5.com
Опубликовал статью Грокаем "память" рынка через дифференцирование и энтропийный анализ Область применения дробного дифференцирования достаточно широка. Например, алгоритмы машинного обучения, обычно, принимают дифференцированный ряд на вход. Проблема в том, что необходимо вывести новые данные в...
 
Hi!
Gostaria de saber como posso continuar obtendo dados ao vivo do mql5 e anexá-los à minha lista ou ao meu dataframe
No momento, uma tabela sai dos comandos do metatrader e é convertida em um dataframe, mas e se quisermos continuar obtendo os dados e anexá-los ao dataframe?
Muito obrigado, você tem sido de grande ajuda
 

Bom dia, estou tendo erro de dll

Traceback (most recent call last):

  File "teste_conexao.py", line 2, in <module>
    from MetaTrader5 import *
  File "C:\Users\anton\AppData\Local\Programs\Python\Python37\lib\site-packages\MetaTrader5\__init__.py", line 35, in <module>
    from .C import *

ImportError: DLL load failed: Não foi possível encontrar o módulo especificado.


alguém sabe o que estou fazendo errado ?

 

<Deleted>

Este é um fórum em inglês. Por favor, poste somente em inglês.

 

Hi,

Alguém poderia escrever um código de exemplo de como abrir uma posição de "compra" ou "venda" no Python e também como fechar essa posição?

Ou talvez isso não seja possível?

Muito obrigado!

 
Antonio Batista:

Bom dia, estou tendo erro de dll

Traceback (most recent call last):

  File "teste_conexao.py", line 2, in <module>
    from MetaTrader5 import *
  File "C:\Users\anton\AppData\Local\Programs\Python\Python37\lib\site-packages\MetaTrader5\__init__.py", line 35, in <module>
    from .C import *

ImportError: DLL load failed: Não foi possível encontrar o módulo especificado.


alguém sabe o que estou fazendo errado ?

Olá Antonio,

esse erro normalmente acontece quando tenta instalar a biblioteca em um python que não é o Python para windows. Tente instalar o https://www.python.org/downloads/  e veja se corrige o erro.


Abraço

Download Python
Download Python
  • www.python.org
The official home of the Python Programming Language
 

O módulo MetaTrader5 não funciona

Importar MetaTrader5 como mt5 funciona assim

mas quando do MetaTrader5 importa * (eu o conecto completamente, ele sai no Pycharme).

Alguém pode me dizer qual é o problema? ?????

 

como conectar um indicador do metatrader5 ao python.


Agradecimentos