Apprendre et écrire ensemble en MQL5 - page 4

 
Bonjour, si quelqu'un peut me dire si j'ai appelé les indicateurs correctement dans mon 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);//il s'agit du CCI

double a4=iMA(NULL,0,21,0,0,0) ;//c'est l'indice de force

return(w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4) ;
}
 
Avelox   :
Bonjour, quelqu'un peut-il me dire si j'ai appelé correctement les indicateurs dans mon 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);//il s'agit du CCI

double a4=iMA(NULL,0,21,0,0,0) ;//c'est l'indice de force

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


non.

iCustom, comme toute autre fonction d 'appel d'indicateur, renvoie le handle de l'indicateur. Lisez la documentation.

 

Merci ! Alors comme ça ! ? double a2 = iCCI(NULL,0,7, 0) ;

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

Le compilateur accepte également la version précédente.

 

Voir un exemple de notre indicateur personnalisé Alligator https://www.mql5.com/en/code/9

Voilà :

  1. Une poignée(iMA) est obtenue
  2. Surveille la quantité de données calculées à partir de ce manche(BarsCalculated)
  3. Copier la partie données(CopyBuffer)
Alligator
Alligator
  • votes : 14
  • 2010.01.26
  • MetaQuotes Software Corp.
  • www.mql5.com
The Alligator Indicator is a combination of Balance Lines (Moving Averages).
 
Avelox   :

Merci ! Alors comme ça ! ? double a2 = iCCI(NULL,0,7, 0) ;

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

Le compilateur sera également satisfait de la variante précédente.


Le compilateur est très bien. J'ai eu un tel fragment de code lors du portage d'un des 4 compilateurs induits :


   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);

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

Ça ressemblait à ça au 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);

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

Je n'ai pas réussi à traduire ligne par ligne car iMAOnArray est absent de la version 5, et je ne veux pas utiliser l'include de la version bêta. Eh bien, au début, j'ai transféré 2*iMa.... je ne pouvais pas comprendre pourquoi la sortie s'avère être nulle. Je commençais à m'énerver. J'étais sur le point d'écrire au forum. Puis j'ai compris - mon habitude a pris le dessus. Le compilateur l'accepte car le handle retourné en 5 a le type de données Int (un nombre, en fait) et il peut être multiplié par 2. Mais la poignée de sortie est une question et cela ne fonctionnera pas de cette façon.

 

Je commence à essayer de migrer le système vers 5 et j'ai immédiatement des problèmes.

//+------------------------------------------------------------------+
//|                                                  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 страницы                                                                     |
//+----------------------------------------------------------------------------------------------------------+
Compile avec 0 erreurs, mais le script ne fonctionne pas :-(
 
maxandsoft   :

Je commence à essayer un système de transfert vers un cinq et c'est un accrochage instantané.

Compile avec 0 erreurs, mais le script ne fonctionne pas :-(


Que voulez-vous dire par "script". A en juger par les fonctions dans le code, vous avez publié le code EA. Regardez la transition avec MQL4
 
Rosh   :


Que voulez-vous dire par le nom "script". A en juger par les fonctions dans le code, vous avez publié le code EA. Regardez la transition avec MQL4


Oui, c'est un EA, textuel bien sûr. Je dois obtenir une réponse du serveur en utilisant wininet.dll.
 
maxandsoft   :


Oui, exactement un conseiller, mot pour mot bien sûr. Je dois obtenir une réponse du serveur en utilisant wininet.dll.

Essayez d'utiliser les versions Unicode de ces fonctions. MQL5 utilise l'encodage Unicode.

 
Rosh   :

Essayez d'utiliser les versions Unicode de ces fonctions. MQL5 utilise Unicode.



Le fait est que lorsque je le compile pendant le débogage, il me renvoie à l'éditeur MQL sans même donner d'erreur. Et lorsque vous le tirez vers le graphique, il n'apparaît même pas sur celui-ci, c'est-à-dire que ni le débogage ni le lancement de l'EA ne donnent d'erreur nulle part.