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

 

Come and help me.

The task is to find the minimum element in array[].

//+------------------------------------------------------------------+ 
//| Получим Lowest для заданного промежутка                          | 
//+------------------------------------------------------------------+ 
double iLowMin(int ot,int bands,double &buffer[])
  {
   double result=-1;
   result=buffer[ArrayMinimum(buffer,ot,bands)];
   return(result);
  }
//+------------------------------------------------------------------+ 
//| Получим High для заданного номера бара                           | 
//+------------------------------------------------------------------+ 
double iHighMax(int ot,int bands,double &buffer[])
  {
   double result=-1;
   result=buffer[ArrayMaximum(buffer,ot,bands)];
   return(result);
  }

The problem is solving it, but the minimum is killing me. Tried everything, input arrays are filled - looked through debugging, what to do?

Print("DwMin  ",iLowMin(rates_total-50,49,ExtLowerBuffer));

Perhaps there are some nuances?

declared via

   SetIndexBuffer(1,ExtLowerBuffer,INDICATOR_DATA);
 
Top2n:

Come and help me.

The task is to find the minimum element in array[].

The problem is solving it, but the minimum is killing me. Tried everything, input arrays are filled - looked through debugging, what to do?

Perhaps there are some nuances?

declared via

Try ArraySort and check what the first index shows.

 

So much for the noosphere, as soon as I gave up the question, I started to come up with a hunch: I have 0 in the array, so it gives out min = 0. But there are still sections with non-zero values, and the min is still 0, well, God forbid, the question is solved)) Thanks to those who simply read, noosphere gave you

 

Attention question))

How do I set the bar in the indicator from which to start processing?

if(prev_calculated>rates_total-Bmax)

{ ... то что нужно обрабатывать начиная с бара[rates_total-Bmax]

}

Tried this, the result is that the indicator makes one move at all.

 

Hello again, could you please tell me, I know the index of an array element, what function can be used to find out its value?

int Totall=OrdersTotal();

double Price; // Price of the selected order

double Mas[]; //array for putting in order all the orders

for(int i=0; i<OrdersTotal(); i++) //order loop

{

if(OrderSelect(i,SELECT_BY_POS)) // if(OrderSelect(i,SELECT_BY_POS))

{Price=OrderOpenPrice(); //Fill array with prices

Mas[i] = Price;

}

}

ArraySort (Mas,WHOLE_ARRAY,0,MODE_ASCEND); // Now the opening prices are ordered in descending order

int Blizko2=ArrayBsearch(Mas,Ask,WHOLE_ARRAY,0,MODE_DESCEND) // The index of the element closest in value to the current price is determined

 
Nauris Zukas:

As I have encountered before studying the classes, again there are nuances that are not described in the articles or somewhere so hidden that it is not possible to find through a search engine. A whole day spent in vain looking for explanations. For example what this symbol means and how it affects if not. As seen below in the example of stati, first it is there and then it is not: &

Also, it's not clear what this symbol means: ~

*

The mql4, mql5 functions always pass an array by reference only (& == ampersand)

First - in the formal parameters of a function - there is an ampersand indicating that it's not the array itself that is passed into the function, but a link to it. And then - inside the function - you are already working with the reference, which means you don't have to specify it again.

The tilde (~) is written before the name of the class destructor - the constructor and destructor have the same name as the class itself, but the destructor has ~.

Read this article about when to use references and when to use pointers.

Although, you still need to read the basics.

 
vikzip:

Hello again, could you please tell me if I know the index of an array element and which function is used to find out its value?

int Totall=OrdersTotal();

double Price; // Price of the selected order

double Mas[]; //array for putting in order all the orders

for(int i=0; i<OrdersTotal(); i++) //order loop

{

if(OrderSelect(i,SELECT_BY_POS)) // If(OrderSelect(i,SELECT_BY_POS)) // If there is a next

{Price=OrderOpenPrice(); //Fill array with prices

Mas[i] = Price;

}

}

ArraySort (Mas,WHOLE_ARRAY,0,MODE_ASCEND); // Now the opening prices are ordered in descending order

int Blizko2=ArrayBsearch(Mas,Ask,WHOLE_ARRAY,0,MODE_DESCEND) // The index of the element closest in value to the current price is determined

Value_element_array = Array[index];

 

Please advise, I have an EA and I've been testing it at work on a normal computer, windows hp. Everything works fine and so on.

I come home, at home laptops macbook, and absolutely with the same parameters on the same tool with the same timeframe shows a completely different result in the tester, any suggestions or ideas why so?

 
Artyom Trishkin:

Array_element_value = Array[index];


Thanks, now there's a new problem. When writing the following condition an error 'PriceBlizko1' - undeclared identifier occurs. Please explain why?

double Price; // Price for the selected order

double Mas[]; // array for putting in order all the orders

for(int i=0; i<OrdersTotal(); i++) // Order loop

{

if(OrderSelect(i,SELECT_BY_POS)) // if(OrderSelect(i,SELECT_BY_POS))

{


Price=OrderOpenPrice(); //Fill array with prices

Mas[i] = Price;

}

}

ArraySort (Mas,WHOLE_ARRAY,0,MODE_ASCEND); // Now opening prices are ordered in descending order

int Blizko1=ArrayBsearch(Mas,Bid,WHOLE_ARRAY,0,MODE_ASCEND); //The index of the element closest in value to the current price is determined

double PriceBlizko1=Mas[Blizko1];

}

if (PriceBlizko1-Bid>=30*Point) //if the lower order is further than 30 points !!!!!! IN THIS STREET!!!!!

OrderSend(Symbol(),OP_SELL,LtsS,Bid,2,0,Bid+30*Point); //Open Sell order

Alert (GetLastError()); //Error message.



 
vikzip:

Use the button to insert code!

Reason: