Aprender y escribir juntos en MQL5 - página 4

 
Hola! Si alguien puede decirme si he llamado correctamente a los indicadores en mi EA?

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

double a4=iMA(NULL,0,21,0,0);//esto es Force Index

return(w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4);
}
 
Avelox   :
Hola, ¿alguien puede decirme si he llamado correctamente a los indicadores de mi EA?

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

double a4=iMA(NULL,0,21,0,0);//esto es Force Index

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


no.

iCustom, como cualquier otra función de llamada a un indicador, devuelve el mango del indicador. Lee la documentación.

 

Gracias. ¿¡Entonces así!? double a2 = iCCI(NULL,0,7, 0);

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

El compilador acepta también la variante anterior.

 

Vea un ejemplo de nuestro indicador Alligator personalizado https://www.mql5.com/en/code/9

Allí:

  1. Se obtiene un mango(iMA)
  2. Controla cuántos datos se calculan a partir de este mango(BarsCalculated)
  3. Copiar la parte de datos(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   :

Gracias. ¿¡Entonces así!? double a2 = iCCI(NULL,0,7, 0);

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

El compilador también se conformará con la variante anterior.


El compilador está bien. Tengo un fragmento de código de este tipo al portar uno de los indukes 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);

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

Se veía así en la 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);

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

No logré traducir línea por línea porque iMAOnArray está ausente en la 5, y no quiero usar el include de la beta. Bueno, al principio transferí 2*iMa.... no pude entender por qué la salida resulta ser una basura. Me estaba enfadando. Estaba a punto de escribir en el foro. Entonces me di cuenta: mi hábito se ha impuesto. El compilador lo acepta porque el manejador devuelto en 5 tiene tipo de datos Int (un número, de hecho) y puede ser multiplicado por 2. Pero la manija de salida es una pregunta y no funcionará así

 

Empiezo a intentar migrar el sistema a 5 y enseguida me meto en 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 страницы                                                                     |
//+----------------------------------------------------------------------------------------------------------+
Compila con 0 errores, pero el script no funciona :-(
 
maxandsoft   :

Empiezo a probar una transferencia de sistema a un cinco y es un enganche instantáneo

Compila con 0 errores, pero el script no funciona :-(


¿Qué quiere decir con "guión"? A juzgar por las funciones del código, ha publicado código EA. Mira la transición con MQL4
 
Rosh   :


A qué se refiere con el nombre de "guión". A juzgar por las funciones del código, ha publicado código EA. Mira la transición con MQL4


Sí, es un EA, al pie de la letra, por supuesto. Necesito obtener una respuesta del servidor usando wininet.dll
 
maxandsoft   :


Sí, exactamente un asesor, al pie de la letra, por supuesto. Necesito obtener una respuesta del servidor usando wininet.dll

Intente utilizar las versiones Unicode de estas funciones. MQL5 utiliza la codificación Unicode.

 
Rosh   :

Intente utilizar las versiones Unicode de estas funciones. MQL5 utiliza Unicode.



El caso es que cuando lo compilo durante la depuración me devuelve al editor MQL sin dar siquiera un error. Y cuando lo sacas al gráfico, ni siquiera aparece en él. Es decir, ni depurando ni lanzando el EA da errores en ningún sitio