Questions des débutants MQL5 MT5 MetaTrader 5 - page 1467

 
Alexey Viktorov #:

Qu'entendez-vous par? Pensez-vous que pour copier un certain nombre d'éléments d'un tableau vers un autre, un certain temp[], vous devez définir la taille du tableau avant la copie ? ArrayResize(temp, new_size) ; ? ????

Non, bien sûr, je voulais dire que la taille du tableau est toujours connue ou peut être connue. Et elle peut et doit être contrôlée en cas de dépassement d'index.

 
Valeriy Yastremskiy #:

Bien sûr que non, je voulais dire que la taille du tableau est toujours connue ou peut être connue. Et elle peut et doit être contrôlée en cas de dépassement d'index.

Vous pouvez la contrôler, mais ce n'est pas toujours nécessaire...

 
Alexey Viktorov #:

Le contrôle est possible, mais pas toujours nécessaire....

Hehe, alors commencez après avoir dépassé les limites))))
 
Valeriy Yastremskiy #:
Hehe, puis démarrer après avoir dépassé)))))

Voici un aperçu...

Forum sur le trading, les systèmes de trading automatisés et les tests de stratégies de trading.

Questions des débutants MQL5 MT5 MetaTrader 5

Alexey Viktorov, 2023.06.27 21:19

Quel est le problème ? Déclarez un tableau temp[] et copiez 30 éléments dedans et cherchez l'index de la valeur minimum/maximum. Et si à la fin il y aura moins de 30, il copiera combien il en reste. Et dans ce cas, je préfère utiliser la boucle while().


Pourquoi dois-je contrôler la taille du tableau temp[] ?

Il faut contrôler la taille du tableau à partir duquel on copie dans temp[], je ne le conteste pas... Mais pourquoi dois-je contrôler la taille du tableau où l'on cherche le maximum/minimum ?

 
Rappelez-moi, s'il vous plaît, s'il y a un appel de connexion de socket web à partir de la DLL appelée par EA, est-il nécessaire d'autoriser l'adresse de l'hôte dans les paramètres du terminal?
 
leonerd paramètres du terminal?

Oui, le terminal ne consulte que les adresses autorisées explicitement.

 
Valeriy Yastremskiy #:

Oui, le terminal ne s'intéresse qu'à ceux qui sont autorisés.

Ce n'est donc pas le terminal qui fouille, c'est la DLL.

 
leonerd #:

Ce n'est donc pas le terminal qui va être impliqué, mais la DLL.

Une dll n'a pas besoin d'un hôte autorisé dans mt. il suffit de permettre l'utilisation d'une dll dans mt. et la dll elle-même peut faire absolument n'importe quoi.

 
Pouvez-vous me dire comment ouvrir un fichier, à l'exception de ShellExecuteW via l'importation de dll ? Existe-t-il une fonction similaire dans winapi.mqh ?
 

Pourriez-vous me dire où ce code ne fonctionne pas correctement ? Il lit les enregistrements au hasard, ne trouve pas tout, et donne de nouveaux résultats à chaque nouveau départ.

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2020, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
input int                  RULE1  = 0;
input int                  RULE2  = 0;
input int                  RULE3  = 0;
input int                  RULE4  = 0;
input bool                 FastComb  = 1;
input int                  FileLine= 20000;
input string               InpFileName="Report.csv";
//+------------------------------------------------------------------+
//| Structure Positions                                              |
//+------------------------------------------------------------------+
struct STRUCT_POSITION
  {
   ENUM_POSITION_TYPE pos_type;              // position type
   bool              waiting_transaction;    // waiting transaction, "true" -> it's forbidden to trade, we expect a transaction
   ulong             waiting_order_ticket;   // waiting order ticket, ticket of the expected order
   bool              transaction_confirmed;  // transaction confirmed, "true" -> transaction confirmed
   //--- Constructor
   STRUCT_POSITION()
     {
      pos_type                   = WRONG_VALUE;
      waiting_transaction        = false;
      waiting_order_ticket       = 0;
      transaction_confirmed      = false;
     }
  };
STRUCT_POSITION SPosition[];
///////////////////////////
struct Report
  {
   long              Pass;
   double            Result;
   double            Profit;
   double            Payoff;
   double            ProfitFactor;
   double            RecoveryFactor;
   double            SharpeRatio;
   long              Custom;
   double            EquityDD;
   long              Trades;
   long               Field1;
   long               Field2;
   long               Field3;
   long               Field4;
   long               Field5;
   long               Field6;
   long               Field7;
   long               Field8;
   long               Field9;
  };
long ProfitComb[20001][10];
///////////////////////////
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(FastComb)
     {
      ArrayInitialize(ProfitComb,-1);
      ReportListComb();
      int FindComb=0;
      for(int i=0; i<=FileLine; i++)
        {
         if(RULE1==ProfitComb[i][1] && RULE2==ProfitComb[i][2] && RULE3==ProfitComb[i][3] && RULE4==ProfitComb[i][4])
           {
            FindComb=1;
            break;
           }
        }
      if(FindComb==0 && RULE1!=0)
         return(INIT_PARAMETERS_INCORRECT);
     }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void ReportListComb()
  {
   Report ReportStr[];
   ResetLastError();
   ArrayResize(ReportStr,FileLine);
   string subfolder="Data";
   int file_handle=FileOpen(subfolder+"\\Report.csv",FILE_READ|FILE_WRITE|FILE_CSV|FILE_ANSI|FILE_COMMON,';');
   if(file_handle!=INVALID_HANDLE)
     {
      int i=0;
      while(!FileIsEnding(file_handle))
        {
         i++;
         ReportStr[i].Pass=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Result=StringToDouble(FileReadString(file_handle));
         ReportStr[i].Profit=FileReadNumber(file_handle);
         ReportStr[i].Payoff=FileReadNumber(file_handle);
         ReportStr[i].ProfitFactor=FileReadNumber(file_handle);
         ReportStr[i].RecoveryFactor=FileReadNumber(file_handle);
         ReportStr[i].SharpeRatio=FileReadNumber(file_handle);
         ReportStr[i].Custom=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].EquityDD=FileReadNumber(file_handle);
         ReportStr[i].Trades=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field1=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field2=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field3=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field4=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field5=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field6=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field7=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field8=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));
         ReportStr[i].Field9=StringToInteger(DoubleToString(FileReadNumber(file_handle),0));

         ProfitComb[i][1]=ReportStr[i].Field1;
         ProfitComb[i][2]=ReportStr[i].Field2;
         ProfitComb[i][3]=ReportStr[i].Field3;
         ProfitComb[i][4]=ReportStr[i].Field4;
         ProfitComb[i][5]=ReportStr[i].Field5;
         ProfitComb[i][6]=ReportStr[i].Field6;
         ProfitComb[i][7]=ReportStr[i].Field7;
         ProfitComb[i][8]=ReportStr[i].Field8;
         ProfitComb[i][9]=ReportStr[i].Field9;
        }
      FileClose(file_handle);
     }
   else
      PrintFormat("Не удалось открыть файл %s, Код ошибки = %d",InpFileName,GetLastError());
  }
//+------------------------------------------------------------------+
Raison: