Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1418

 
Alexey Belyakov #:

Good evening, dear programmers!

Help me to solve a simple problem. There is a code from MQL4. I want to adapt it to 5. That is, it should work similarly in MQL5.


Look in the help

iHigh

and similar functions

If it doesn't work, there is an error in the loop.

and you can't see which variable you are adding data to

 
lynxntech #:

look in the help

and similar functions

if it doesn't work, there is an error in the loop

and you can't see what variable you are adding data to

Highest / Lowest is supposed to show.

Looked at this :

int val_index=iLowest(NULL,0,MODE_CLOSE,10,1);

Very close, but not yet.

Well, it shows the NUMBER of the last 10 (starting from the first "1") candlestick with the most low. But I need the price value, not the candle number.

 

In general, it is necessary not to look backwards, but forwards.

For example: search for the "minimum" from the beginning of the previous candle (which is numbered "1") during the next 100 candles.

 
lynxntech #:

it can all be done, the question was to those who measured the actual work, and better to the developers, who knows what they have in their plans there

Idon't want to experiment, there are many other tasks.

Right. Not a royal business in .........

 
Alexey Viktorov #:

That's right. Not the king's business at .........

maybe we should close the Questions from beginners thread? Alexei, if you don't want to help, please stay out of it, there are too many complaints from you.

I was interested in a professional answer to have an idea how the platform works.

 
Alexey Belyakov #:

Good evening, dear programmers!

Help me to solve a simple problem. There is a code from MQL4. I want to adapt it to 5. That is, it should work similarly in MQL5.




My variant obviously does not work, for some reason there are a lot of errors):

Apparently, you are completely unfamiliar with programming. That's why whatever advice you are given, you won't succeed so far .

But nevertheless... try to understand the function

int  CopyHigh(
   string           symbol_name,      // имя символа
   ENUM_TIMEFRAMES  timeframe,        // период
   int              start_pos,        // откуда начнем 
   int              count,            // сколько копируем
   double           high_array[]      // массив для копирования максимальных цен
   );

and the function of working with arrays

int  ArrayMaximum(
   const void&   array[],             // массив для поиска
   int           start=0,             // с какого индекса начинаем поиск
   int           count=WHOLE_ARRAY    // количество проверяемых
   );

There are other variants of solving this problem.

 
Alexey Belyakov #:

Good evening, dear programmers!

Help me to solve a simple problem. There is a code from MQL4. I want to adapt it to 5. That is, it should work similarly in MQL5.




My variant obviously does not work, for some reason there are a lot of errors):

CopyRates() instead of a bunch of indicators and code edits will become minimal, the code will remain compact and readable.

//Введем внешнюю переменную, чтобы иметь возможность изменить количество сканируемых свечей.
extern int Window=30;
 
void OnStart()
{
   //Вводим переменные.
   double Highest=DBL_MIN;// 
   double Lowest=DBL_MAX; // 
   MqlRates rates[];
   //Сканируем 30 свечей и обновляем значения самых высоких и самых низких цен.
   if (CopyRates(_Symbol,_Period,30,rates)!=30) {
      Alert("copyRates failed");
      return;
   }
   for(int i=0; i<=Window; i++) {
      if(rates[i].low<Lowest) Lowest=rates[i].low;
      if(rates[i].high>Highest) Highest=rates[i].high;  
   }
 
   //Выводим результат.
   Alert("Самая высокая цена ",Highest," - Самая низкая цена ",Lowest);
}

In reality, you should also add a check for curved quotes

 
Maxim Kuznetsov #:

CopyRates() instead of a bunch of indicators and code edits will become minimal, the code will remain compact and readable.

In reality, you should also add a check for curved quotes

Maxim, isn't CopyRates presented as getting all the features of a symbol?

cheaper there are individual functions

 
lynxntech #:

Maxim, isn't CopyRates presented as getting all the features of the character?

cheaper there are individual features

there 1) according to developers' words virtual copying, i.e. if possible data are not transferred, internal references are transferred 2) even with full copying it is faster than CopyBuffer for iHigh,iLow separately (1 call instead of 2, which will still go into the same terminal structures).

and finally, the main thing: when porting, it is very important that the code should be as similar to the original as possible, even visually. You must be absolutely sure that it (the code) does exactly the same thing as the original. And small-optimisations are done afterwards, and only where it is really critical.

 
Maxim Kuznetsov #:

there 1) according to the developers virtual copying, i.e. if possible data are not transferred, internal references are transferred 2) even with full copying it is faster than CopyBuffer for iHigh,iLow separately (1 call instead of 2, which will still go to the same terminal structures).

and finally, the main thing: when porting, it is very important that the code should be as similar to the original as possible, even visually. You must be absolutely sure that it (the code) does exactly the same thing as the original. And small-optimisations are done afterwards, and only where it is really critical.

It's an eternal problem that developers don't want to answer.

that it is cheaper to get everything at once, or two necessary parts.

to my last question, in another thread they also didn't say anything, apparently they are busy with something else. or rather they don't know themselves. and there is no one to find out.