Aide à la mise à niveau vers MetaTrader 5 sans perte de données - page 13

 
mario065:

Bonjour,

Je ne pouvais pas faire ce que je voulais.

J'ai un tampon de mouillage différent dans ma tête, j'ai une paire différente, que celle que j'avais dans ma tête.

[code]
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_plots   2
#property indicator_type1   DRAW_COLOR_LINE
#property indicator_type2   DRAW_COLOR_LINE
#property indicator_color1  clrBlue
#property indicator_color2  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_style2  STYLE_SOLID

input int period_1 = 20;
input int period_2 = 100;
input ENUM_MA_METHOD ma_method = MODE_SMA;
input ENUM_APPLIED_PRICE applied_price = PRICE_CLOSE;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
int EMHandle1=0;
int EMHandle2=0;
int EMHandle11=0;
int EMHandle22=0;
MqlParam params[];      // Структура за съхранение  параметрите на индикатора
double ma1[],ma2[],ma3[],ma4[];//Временни буфери

int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0, ExtMapBuffer1, INDICATOR_DATA);
   SetIndexBuffer(1, ExtMapBuffer2, INDICATOR_DATA);
   SetIndexBuffer(2, ma1, INDICATOR_DATA);
   SetIndexBuffer(3, ma2, INDICATOR_DATA);
   SetIndexBuffer(4, ma3, INDICATOR_DATA);
   SetIndexBuffer(5, ma4, INDICATOR_DATA);
  
   PlotIndexSetInteger(0, PLOT_SHIFT, 0);
   PlotIndexSetInteger(1, PLOT_SHIFT, 0);
  
   PlotIndexSetInteger(0,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(1,PLOT_LINE_STYLE,STYLE_SOLID);
//---
   PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrBlue);
   PlotIndexSetInteger(1,PLOT_LINE_COLOR,clrRed);

   PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_LINE);
   IndicatorSetString(INDICATOR_SHORTNAME,"2_2_MA");
//--- set accuracy
   IndicatorSetInteger(INDICATOR_DIGITS,4);  
//---
   ArrayResize(params,4);
   params[0].type         =TYPE_INT;
   params[0].integer_value=period_1;
   // Смещение
   params[1].type         =TYPE_INT;
   params[1].integer_value=0;
   // Метод расчета: простое усреднение
   params[2].type         =TYPE_INT;
   params[2].integer_value=MODE_SMA;
   // Тип цен для рассчета: цены закрытия
   params[3].type         =TYPE_INT;
   params[3].integer_value=PRICE_CLOSE;
  
   EMHandle1 = IndicatorCreate(_Symbol, 0, IND_MA, 4, params);
   ArrayResize(params,4);
   params[0].type         =TYPE_INT;
   params[0].integer_value=period_2;
   params[1].type         =TYPE_INT;
   params[1].integer_value=0;
   params[2].type         =TYPE_INT;
   params[2].integer_value=MODE_SMA;
   params[3].type         =TYPE_INT;
   params[3].integer_value=PRICE_CLOSE;
  
   EMHandle2 = IndicatorCreate(_Symbol, 0, IND_MA, 4, params);
   ArrayResize(params,4);
   params[0].type         =TYPE_INT;
   params[0].integer_value=period_1;
   params[1].type         =TYPE_INT;
   params[1].integer_value=0;
   params[2].type         =TYPE_INT;
   params[2].integer_value=MODE_SMA;
   params[3].type         =TYPE_INT;
   params[3].integer_value=PRICE_CLOSE;
  
   EMHandle11 = IndicatorCreate(_Symbol, 0, IND_MA, 4, params);
   ArrayResize(params,4);
   params[0].type         =TYPE_INT;
   params[0].integer_value=period_2;
   params[1].type         =TYPE_INT;
   params[1].integer_value=0;
   params[2].type         =TYPE_INT;
   params[2].integer_value=MODE_SMA;
   params[3].type         =TYPE_INT;
   params[3].integer_value=PRICE_CLOSE;
  
   EMHandle22 = IndicatorCreate(_Symbol, 0, IND_MA, 4, params);
     
   return(0);
}
int OnCalculate (const int rates_total,    // размер массива price[];
                 const int prev_calculated,// количество доступных баров ;на предыдущем вызове;
                 const int begin,// с какого индекса в массиве  price[] начинаются достоверные данные;
                 const double &price[]) // массив, по которому и будет считаться индикатор;
  {
   int i;
   ArraySetAsSeries(ma1, true);
   ArraySetAsSeries(ma2, true);
   ArraySetAsSeries(ma3, true);
   ArraySetAsSeries(ma4, true);
  
   if(CopyBuffer(EMHandle1, 0, 0, 1, ma1) < 0){Print("CopyBuffer ma1 error =", GetLastError());}
   if(CopyBuffer(EMHandle2, 0, 0, 1, ma2) < 0){Print("CopyBuffer ma2 error =", GetLastError());}
   if(CopyBuffer(EMHandle11, 0, 0, 1, ma3) < 0){Print("CopyBuffer ma3 error =", GetLastError());}
   if(CopyBuffer(EMHandle22, 0, 0, 1, ma4) < 0){Print("CopyBuffer ma4 error =", GetLastError());} 
   int limit;
   //if(prev_calculated<1)
      //limit=period_1;
      limit=prev_calculated-1;
   for( i=0; i<limit; i++)
   ExtMapBuffer1[0]=вычисление;
   ExtMapBuffer2[0]=вычисление;

      Comment(
      "\n=====================",
      "\n ma1[0]     :   ",DoubleToString(ma1[0],5),
      "\n ma2[0]     :   ",DoubleToString(ma2[0],5),
      "\n ma3[0]     :   ",DoubleToString(ma3[0],5),
      "\n ma4[0]     :   ",DoubleToString(ma4[0],5),
      "\n ExtMapBuffer1[0] : ",DoubleToString(ExtMapBuffer1[0],4),
      "\n ExtMapBuffer2[0] : ",DoubleToString(ExtMapBuffer2[0],4)
      );
       return(rates_total);
  }
void OnDeinit(const int reason)
  {
   Comment("");      
  }
[/code] 

Lorsque 0 au lieu de i (pour une barre) je vois le résultat, lorsque la barre (courant = i) montre que je ne peux pas trouver de données pour la deuxième paire.

Le graphique de la paire est ouvert, dans la fenêtre du marché, je ne sais pas où je confonds les choses.

Deux paires différentes dans un seul indicateur - alors où est mon erreur ?

J'essaie de mettre 0 et de voir le résultat sous forme de commentaire, mais je n'ai pas de ligne.

Pour clarifier : j'ai mis ma1 et ma2 sur une paire et ma3 et ma4 sur l'autre paire.

Merci.

Tout d'abord, vous comptez à partir de 0----->prev_calculated-1 et vous devez compter à partir de la dernière barre comptée jusqu'au taux_total.

ceci :

      limit=prev_calculated-1;
   for( i=0; i<limit; i++)
   ExtMapBuffer1[0]=вычисление;

changez-le en ceci :

   
   for(int i=prev_calculated-1>=0?prev_calculated-1:0; i<rates_total; i++)
       ExtMapBuffer1[i]=вычисление;

La deuxième chose que je ne comprends pas vraiment, voulez-vous obtenir des muwings de différents instruments ou de différentes périodes, je n'ai pas trouvé l'un ou l'autre dans le code.

 

Bonne journée, messieurs !

Qui peut m'aider à adapter les indicateurs suivants pour le MT5 (pré-fichiers).

Je vous offre 10 dollars pour une bière pour le travail.

Dossiers :
 
master_kiln:

Bonne journée, messieurs !

Qui peut m'aider à adapter les indicateurs suivants pour le MT5 (pré-fichiers).

Je vous offre 10 dollars pour une bière pour le travail.

https://www.mql5.com/ru/job
MQL5 работа
MQL5 работа
  • www.mql5.com
Заказы на разработку программ для трейдинга
 

Urain,

Merci de votre attention.

Je ne peux pas le faire dessiner. Si tu peux, mets-le ici.

Je pense que c'est cool de faire différentes paires et différents cadres dans xpert.

//+------------------------------------------------------------------+
//|2_2_v2.mq5 |
//|Yuriy Tokman |
//| yuriytokman@gmail.com|
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#lien de propriété"yuriytokman@gmail.com"
#propriété version "1.00"
#propriété indicator_separate_window
#property indicator_buffers 6
#property indicator_plots 2
#property indicator_type1 DRAW_COLOR_LINE
#property indicator_type2 DRAW_COLOR_LINE
#propriété indicator_color1 clrBlue
#property indicator_color2 clrRed
#propriété indicator_style1 STYLE_SOLID
#propriété indicator_style2 STYLE_SOLID
//#property indicator_label1 "EURUSD"
//#property indicator_label2 "GBPUSD" (en anglais)

entrée int period_1 = 13 ;
entrée int period_2 = 55 ; ;
entrée ENUM_MA_METHOD ma_method = MODE_SMA ;
input ENUM_APPLIED_PRICE applied_price = PRICE_CLOSE ;

double ExtMapBuffer1[] ;
double ExtMapBuffer2[] ;
int EMHandle1 ;
int EMHandle2; ;
int EMHandle11 ;
int EMHandle22 ;
double ma1[],ma2[],ma3[],ma4[];//tampon de temps
double p1 = SymbolInfoDouble("EURUSD",SYMBOL_POINT) ;
double p2 = SymbolInfoDouble("GBPUSD",SYMBOL_POINT) ;
//+------------------------------------------------------------------+
//| Fonction d'initialisation de l'indicateur personnalisé |
//+------------------------------------------------------------------+
int OnInit()
{
//--- cartographie des tampons indicateurs
SetIndexBuffer(0, ExtMapBuffer1, INDICATOR_DATA) ;
SetIndexBuffer(1, ExtMapBuffer2, INDICATOR_DATA) ;
SetIndexBuffer(2, ma1, INDICATOR_DATA) ;
SetIndexBuffer(3, ma2, INDICATOR_DATA) ;
SetIndexBuffer(4, ma3, INDICATOR_DATA) ;
SetIndexBuffer(5, ma4, INDICATOR_DATA) ;

PlotIndexSetInteger(0, PLOT_SHIFT, 0) ;
PlotIndexSetInteger(1, PLOT_SHIFT, 0) ;

PlotIndexSetInteger(0,PLOT_LINE_STYLE,STYLE_SOLID) ;
PlotIndexSetInteger(1,PLOT_LINE_STYLE,STYLE_SOLID) ;
//---
PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrBlue) ;
PlotIndexSetInteger(1,PLOT_LINE_COLOR,clrRed) ;

PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,1) ;
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,1) ;

PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE) ;
PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_LINE) ;

//--- nom pour DataWindow
IndicatorSetString(INDICATOR_SHORTNAME, "2_2_MA") ;
//---
//--- définir la précision
IndicatorSetInteger(INDICATOR_DIGITS,4) ;

EMHandle1 = iMA("EURUSD", 0, period_1, 0, ma_method, applied_price) ;
EMHandle2 = iMA("EURUSD", 0, period_2, 0, ma_method, applied_price) ;
EMHandle11 = iMA("GBPUSD", 0, period_1, 0, ma_method, applied_price) ;
EMHandle22 = iMA("GBPUSD", 0, period_2, 0, ma_method, applied_price) ;

ArraySetAsSeries(ExtMapBuffer1,true) ;
ArraySetAsSeries(ExtMapBuffer2,true) ;
ArraySetAsSeries(ma1,true) ;
ArraySetAsSeries(ma2,true) ;
ArraySetAsSeries(ma3,true) ;
ArraySetAsSeries(ma4, true) ;

//---
retour(0) ;
}
//+------------------------------------------------------------------+
//| Fonction d'itération de l'indicateur personnalisé |
//+------------------------------------------------------------------+
int OnCalculate (const int rates_total,// taille du tableau price[] ;
const int prev_calculated,// nombre de barres disponibles ;sur l'appel précédent ;
const int begin,// quel index dans le tableau price[] commencera les données valides ;
const double &price[]) // tableau, sur lequel l'indicateur sera calculé ;
{
if(CopyBuffer(EMHandle1, 0, 0, 1, ma1) < 0){Print("CopyBuffer ma1 error =", GetLastError());}
if(CopyBuffer(EMHandle2, 0, 0, 1, ma2) < 0){Print("CopyBuffer ma2 error =", GetLastError());}
if(CopyBuffer(EMHandle11, 0, 0, 1, ma3) < 0){Print("CopyBuffer ma3 error =", GetLastError());}
if(CopyBuffer(EMHandle22, 0, 0, 1, ma4) < 0){Print("CopyBuffer ma4 error =", GetLastError());}

ExtMapBuffer1[0]=(ma1[0]-ma2[0])/p1;
ExtMapBuffer2[0]=(ma3[0]-ma4[0])/p2;

Commentaire(
"\n=====================",
"\n ma1[] : ",DoubleToString(ma1[0],5),
"\n ma2[] : ",DoubleToString(ma2[0],5),
"\n ma3[] : ",DoubleToString(ma3[0],5),
"\n ma4[] : ",DoubleToString(ma4[0],5),
"\n ExtMapBuffer1[] : ",DoubleToString(ExtMapBuffer1[0],4),
"\n ExtMapBuffer2[] : ",DoubleToString(ExtMapBuffer2[0],4)
) ;
//---

//--- retour de la valeur de prev_calculée pour l'appel suivant
retour(taux_total) ;
}
void OnDeinit(const int reason)
{
Commentaire (") ;
}
//+------------------------------------------------------------------+

 

Bonne journée à tous.

J'ai une demande pour refaire cet indicateur pour MT5 car je l'utilise uniquement en trading.

Dossiers :
 

Je ne sais pas où écrire, mais peut-être pouvez-vous m'aider à résoudre ce problème : Dans MT4, je copie simplement un EA dans le dossier des experts, je le mets dans Strategy Tester, tout semble bon et fonctionne, mais dans MT5, je ne comprends pas comment tester un EA, je le mets dans le dossier des experts avec l'extension .Je les ai copiés et collés ailleurs. Pouvez-vous me dire comment copier un EA et où le coller correctement ?

 
ZahvatkiN:

Je ne sais pas où écrire, mais peut-être pouvez-vous m'aider à résoudre ce problème : Dans MT4, je copie simplement un EA dans le dossier des experts, je le mets dans Strategy Tester, tout semble bon et fonctionne, mais dans MT5, je ne comprends pas comment tester un EA, je le mets dans le dossier des experts avec l'extension .Je les ai copiés et collés ailleurs. Pouvez-vous me dire comment copier correctement un EA et où le coller ?

Vous pouvez exécuter les deux dans le testeur et en temps réel, vous pouvez seulement exécuter un EA avec l'extension ex5 ou la version compilée,

Si vous ouvrez un fichier mq5 dans MetaEditor, appuyez sur F7 et vous serez satisfait. Le code source avec l'extension mq5, c'est seulement une information de test, afin d'obtenir le byte-code (code exécutable) de celui-ci, vous devez le compiler.

 

Urain merci pour la réponse, seulement je connais toutes les bases, j'ai compilé et fait tout selon les instructions, même si je le savais, mais encore une fois je l'ai lu, je ne sais pas ce qui pourrait être faux, voici 2 skins attachés. J'ai téléchargé MT5 à partir de ce site.

Dossiers :
1__17.jpg  420 kb
2__10.jpg  117 kb
 
ZahvatkiN:

Urain merci pour la réponse, seulement je connais toutes les bases, j'ai compilé et fait tout selon les instructions, même si je le savais, mais encore une fois je l'ai lu, je ne sais pas ce qui pourrait être faux, voici 2 skins attachés. J'ai téléchargé MT5 à partir de ce site.

Je veux placer ma copie de grr-al.ex5 dans le bon dossier et recharger MT5 après m'être assuré qu'elle se trouve dans le bon dossier.

Au fait, MT5 est-il le seul à fonctionner sur l'ordinateur ?

 

Urain a enfin trouvé la solution, le truc c'est que les EAs ne sont pas copiés dans le dossier C:\Program Files\MT5\MQL5\Experts mais dans C:\Users\Dyma\\AppData\Roaming\MetaQuotes\Terminal\8B052D0699A0083067EBF3A36123603B\MQL5\Experts, je ne sais pas pourquoi cette galère, ces satanés programmeurs))))

Raison: