Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1606

 
Alexey Viktorov #:

Read the rules. The EA should work without restrictions on both instruments and TFs.

Thank you! There were a lot of other errors in the process)

 
The question is whether you can initialize multidimensional arrays with the function

ArrayInitialize(array,EMPTY_VALUE);
Like this double msArr[10][4][500];
Or it can be done only in loop in MKL4
.

 
Valeriy Yastremskiy multidimensional arrays can be initialized with the function

ArrayInitialize(array,EMPTY_VALUE);
Like this double msArr[10][4][500];
Or it can only be done in loop in MKL4
.

There are also ArrayFill and ZeroMemory

Multidimensional array when processing with ArrayFill() appears as one-dimensional, for example, array[2][4] is processed as array[8], so when working with this array it's acceptable to specify index of initial element equal to 5. So, call ArrayFill(array, 5, 2, 3.14) for array[2][4] will fill array[1][1] and array[1][2] with value 3.14.

 
Taras Slobodyanik #:

There is also ArrayFill and ZeroMemory

Thank you
 
MakarFX #:

This way!

And you're a joker. And the problem really is, and there are topics about that the command Print prints twice in the tab Experts and Allert also comes twice, only there is no answer alas how to fix it. And for the future, if you do not know, you can just keep silent and pass by, but to gain rating themselves unprofessional answers is stupid. Yes, by the way, your answers are really very weak.

 
Manter84 #:

You're a joker. But the problem is real, and there are topics about that the command Print prints twice in the tab Experts and Allert also comes twice, only there is no answer alas how to fix it. And for the future, if you do not know, you can just keep silent and pass by, but to gain rating themselves unprofessional answers is stupid. Yes, by the way, your answers are really very weak.

You didn't understand my link...

Print doesn't print more than once, if it does, there's an error in the code...that's why I sent you to the telepaths, as you haven't posted the code)

 

Good night!

Dear forum users, I need some help. I wrote a script in MQL4 that draws a line by a formula from three given points on a chart. It takes 130 lines, including indents and spaces. I have recently decided to port it to MQL5 and realized that my poor knowledge in programming will not help me, I need to learn again.

I will be grateful if someone is ready to port the script to MQL5. I would be glad if somebody would like to port this script to MQL5.

 
Андрей do not hesitate to message me in person.

I would be glad if somebody would do it for free (with).

 
 #property copyright "ExpoMe"
 #property link      "http://www.metaquotes.net"

 #property indicator_chart_window
 #property indicator_buffers 1
 #property  indicator_color1 Blue
 #property  indicator_width1 2
 #property  indicator_style1 0
 double     Buffer1[];
 //+------------------------------------------------------------------+
 //| Объявляем внешние переменные                                     |
 //+------------------------------------------------------------------+
 datetime point_1;
 datetime point_2;
 datetime point_3;
 datetime LastBarTime;
 string line_name[10];
 int gg=1;
 int x1;
 int x2;
 int x3;
 int xx1; // В эту переменную сохраняется значение номера бара вершины перед прогоном при появлении нового бара.
 int xx2; // Если линии стоят, значит при поялвении нового бара номер бара вершины должен увеличиться на 1.
 int xx3; // Если этого не произошло и xx1=x1 после прогона, значит увеличиваем вручную.
 int max;
 int maxx;
 double y1;
 double y2;
 double y3;
 double y11;
 double y22;
 double y33;
 double x11;
 double x22;
 double x33;
 double y;
 double a1;
 double a2;
 double a3;

 //+------------------------------------------------------------------+
 //| Custom indicator initialization function                         |
 //+------------------------------------------------------------------+
 int init()
   {SetIndexBuffer(0,Buffer1);
   SetIndexStyle(0,DRAW_LINE);
 //---- indicators
 //----
    return(0);
   }
  
 int start()
   {
   // Пересчитываем инликатор только при появлении нового бара
   if(LastBarTime == iTime(Symbol(), 0, 0))
      return(0);
    LastBarTime = iTime(Symbol(), 0, 0);
   
   
 // Присваиваем значения переменных времени


 int obj_total=ObjectsTotal();

   for(int ii=0;ii<100;ii++)
     {string name = ObjectName(ii);
       if(ObjectType(name)!=OBJ_VLINE)
       continue;
       line_name[gg] = ObjectName(ii);
       gg=gg+1;
     
     }
    
   
    point_1=ObjectGet(line_name[1], OBJPROP_TIME1);
    point_2=ObjectGet(line_name[2], OBJPROP_TIME1);
    point_3=ObjectGet(line_name[3], OBJPROP_TIME1);
   
 // Запоминаем текущий номер бара вершины

 xx1=x1; 
    
 //Определяем номера баров ключевых точек
   for (int j=0;j<Bars; j++)
   { if (Time[j]==point_1) x1=j;}
  
  
   // Если после прогона сдвиг по вершине не произошел, значит линий нет, добавляем +1 вручную.
 if (x1==xx1) x1=x1+1;
  
  
 xx2=x2;
  
   for (int k=0;k<Bars; k++)
   {if (Time[k]==point_2) x2=k;  }
  
 if (x2==xx2) x2=x2+1;
  
 xx3=x3;

   for (int l=0;l<Bars; l++)
   {if (Time[l]==point_3) x3=l; }
  
 if (x3==xx3) x3=x3+1;

 // Comment ("n1=", j," n2=", k, " n3=", l);
 //Находим "высоту" вершин
   {
   y1=High[x1];
   y2=High[x2];
   y3=High[x3];
   //Comment ("y1=", y1," x1=", x1, " y2=", y2, "x2=", x2," y3=", y3, " x3=", x3);
   //Принимаем первую из них за начало координат
  
 a1=(y3-(x3*(y2-y1)+x2*y1-x1*y2)/(x2-x1))/(x3*(x3-x1-x2)+x1*x2);
 a2=((y2-y1)/(x2-x1))-a1*(x1+x2);
 a3=((x2*y1-x1*y2)/(x2-x1))+a1*x1*x2;

 max=MathMax(x1,x2);
 maxx=MathMax(max,x3);
  
  
   for (int i=maxx; i>=0; i--)
  
   { y=a1*i*i+a2*i+a3;
   Buffer1[i]=y;}
  

    return(0);
   }} 

MetaQuotes — разработчик торговых платформ для брокеров, банков, бирж и хедж-фондов
MetaQuotes — разработчик торговых платформ для брокеров, банков, бирж и хедж-фондов
  • www.metaquotes.net
Торговая платформа MetaTrader 5 - это бесплатный инструмент трейдера, позволяющий торговать на форексе и фондовых биржах
 
Vitaly Muzichenko #:

Throw the code in here, maybe someone will do it for free(c), it happens

If someone helps, I owe you a whisky anyway!)
Reason: