Aprender e escrever juntos em MQL5 - página 4

 
Olá! se alguém me puder dizer se chamei correctamente os indicadores na minha EA?

double perceptron()
{
double w1 = x1 - 100;
double w2 = x2 - 100;
double w3 = x3 - 100;
double w4 = x4 - 100;
double a1 = iCustom(NULL,0, "CCI Personalizado", 0);
double a2 = iCustom(NULL,0, "CCI Personalizado", 7)
double a3 = iCustom(NULL,0, "CCI Personalizado", 14);//isto é CCI

double a4=iMA(NULL,0,21,0,0,0,0);//isto é Índice de Força

return(w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4);
}
 
Avelox   :
Olá, alguém me pode dizer se chamei correctamente os indicadores na minha EA?

double perceptron()
{
double w1 = x1 - 100;
double w2 = x2 - 100;
double w3 = x3 - 100;
double w4 = x4 - 100;
double a1 = iCustom(NULL,0, "CCI Personalizado", 0);
double a2 = iCustom(NULL,0, "CCI Personalizado", 7)
double a3 = iCustom(NULL,0, "CCI Personalizado", 14);//isto é CCI

double a4=iMA(NULL,0,21,0,0,0,0);//isto é Índice de Força

return(w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4);
}


não.

iCustom, como qualquer outra função de chamada de indicador, devolve o manípulo do indicador. Leia a documentação.

 

Obrigado! Então assim!? double a2 = iCCI(NULL,0,7, 0);

double a4=iForce(NULL,0,21,0,0);

O compilador aceita também a variante anterior.

 

Ver um exemplo do nosso indicador personalizado de crocodilo https://www.mql5.com/en/code/9

Aí:

  1. Obtém-se uma pega(iMA)
  2. Monitora quantos dados são calculados a partir deste cabo(BarsCalculated)
  3. Copiar a parte de dados(CopyBuffer)
Alligator
Alligator
  • votos: 14
  • 2010.01.26
  • MetaQuotes Software Corp.
  • www.mql5.com
The Alligator Indicator is a combination of Balance Lines (Moving Averages).
 
Avelox   :

Obrigado! Então assim!? double a2 = iCCI(NULL,0,7, 0);

double a4=iForce(NULL,0,21,0,0);

O compilador ficará também satisfeito com a variante anterior.


O compilador está muito bem. Tenho um tal fragmento de código ao portar uma das induções de 4-compiladores:


   iMA1Handle=iMA(NULL,0,Period1/2,0,3,PRICE_CLOSE); // Не забыть потом перемножить на 2
   iMA2Handle=  iMA(NULL,0, Period1,   0,3,PRICE_CLOSE);
   SQPeriod=NormalizeDouble(MathSqrt(Period1),0);

... Бла-бла-бла ...

Parecia assim em 4:

   while (i>=0)
      {
         ExtMapBuffer2[i]=2*iMA(NULL,0,PeriodX/2,0,3,PRICE_CLOSE,i);
         ExtMapBuffer3[i]=  iMA(NULL,0, PeriodX,0,3,PRICE_CLOSE,i);
         ExtMapBuffer4[i]=ExtMapBuffer2[i]-ExtMapBuffer3[i];
         i--;
      }
   i=i2; // Возврат i для расчёта значений индюка
   while (i>=0)
      {
         ExtMapBuffer1[i]=iMAOnArray(ExtMapBuffer4,0,NormalizeDouble(MathSqrt(PeriodX),0),0,3,i);

... Бла-бла-бла ...

Não consegui traduzir linha a linha, porque o iMAOnArray está ausente em 5, e não quero usar incluir a versão beta. Bem, no início transferi 2*iMa.... não consegui perceber porque é que a saída se revela uma porcaria. Eu estava a ficar furioso. Estava prestes a escrever para o fórum. Depois descobri-o - o meu hábito tomou conta. O compilador aceita-o porque o cabo devolvido em 5 tem o tipo de dados Int (um número, de facto) e pode ser multiplicado por 2. Mas o punho de saída é uma grande questão e não vai funcionar dessa forma

 

Começo a tentar migrar o sistema para 5 e imediatamente meto-me em problemas

//+------------------------------------------------------------------+
//|                                                  GetInternet.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"

#import "wininet.dll"
  int InternetAttemptConnect (int x);
  int InternetOpenA(string sAgent, int lAccessType, 
                    string sProxyName = "", string sProxyBypass = "", 
                    int lFlags = 0);
  int InternetOpenUrlA(int hInternetSession, string sUrl, 
                       string sHeaders = "", int lHeadersLength = 0,
                       int lFlags = 0, int lContext = 0);
          
  int InternetReadFile(int hFile, int& sBuffer[], int lNumBytesToRead, 
                       int& lNumberOfBytesRead[]);
  int InternetCloseHandle(int hInet);


#import "stdlib.ex5"
#import
input int Step = 300;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("Старт...");
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
    Comment(GetURL("http://www.forexremote.net"));
    
  }
//+------------------------------------------------------------------+


//+----------------------------------------------------------------------------------------------------------+
//| Функция получения WEB страницы                                                                           |
//+----------------------------------------------------------------------------------------------------------+
string GetURL(string url)
{
   int rv = InternetAttemptConnect(0);
   if(rv != 0)
     {
       Alert("Ошибка при вызове InternetAttemptConnect()");
       return("");
     }

   int hInternetSession = InternetOpenA("Microsoft Internet Explorer", 1, "", "", 0);
   if(hInternetSession <= 0)
     {
       Alert("Ошибка при вызове InternetOpenA()");
       return("");         
     }

   int hURL = InternetOpenUrlA(hInternetSession, url, "", 0, 0, 0);
   if(hURL <= 0)
    {
       Print("Ошибка получения данных с узла!");
       //fComment("Ошибка получения данных с узла!",true);
       InternetCloseHandle(hInternetSession);
       return("");         
     } 
          
   int cBuffer[256];
   int dwBytesRead[1]; 
   string TXT = "";
   while(!IsStopped())
     {
       bool bResult = InternetReadFile(hURL, cBuffer, 1024, dwBytesRead);
       if(dwBytesRead[0] == 0)
           break;
       string text = "";   
       for(int i = 0; i < 256; i++)
         {
              text = text + CharToString(cBuffer[i] & 0x000000FF);
              if(StringLen(text) == dwBytesRead[0])
                  break;
              text = text + CharToString(cBuffer[i] >> 8 & 0x000000FF);
              if(StringLen(text) == dwBytesRead[0])
                  break;
           text = text + CharToString(cBuffer[i] >> 16 & 0x000000FF);
           if(StringLen(text) == dwBytesRead[0])
               break;
           text = text + CharToString(cBuffer[i] >> 24 & 0x000000FF);
         }
       TXT = TXT + text;
       //Sleep(500);

     }
     InternetCloseHandle(hInternetSession);
     return(TXT);
}
//+----------------------------------------------------------------------------------------------------------+
//| Конец Функции получения WEB страницы                                                                     |
//+----------------------------------------------------------------------------------------------------------+
Compilar com 0 erros, mas o guião não funciona :-(
 
maxandsoft   :

Começo a tentar uma transferência do sistema para um cinco e é um engate instantâneo

Compilar com 0 erros, mas o guião não funciona :-(


O que quer dizer com "guião". A julgar pelas funções do código, publicou o código EA. Veja Transição com MQL4
 
Rosh   :


O que quer dizer com o nome "guião". A julgar pelas funções do código, publicou o código EA. Veja a Transição com MQL4


Sim, é uma EA, literalmente, claro. Preciso de obter uma resposta do servidor utilizando wininet.dll
 
maxandsoft   :


Sim, exactamente um conselheiro, literalmente, claro. Preciso de obter uma resposta do servidor utilizando wininet.dll

Tente utilizar versões Unicode destas funções. A MQL5 utiliza codificação Unicode.

 
Rosh   :

Tente utilizar versões Unicode destas funções. A MQL5 utiliza Unicode.



A questão é que quando a compilo durante a depuração atira-me de volta para o editor MQL sem sequer dar um erro. E quando se puxa para o gráfico, este nem sequer aparece nele. Ou seja, nem a depuração nem o lançamento da EA dá erros em qualquer lugar