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

 
Vitaly Muzichenko #:

Copying to an array

How do I get the maximum high in the array?

You can write it directly in the code:

MqlRates CopySymb[];
double maxHigh;
int iMaxHi, len;  

if((len = CopyRates(mSymbol,PERIOD_CURRENT,0,6,CopySymb))<0) return;

iMaxHi = 0;
maxHigh = CopySymb[0].high;

for (int i = 1; i < len; i++)
  if(CopySymb[i].high > maxHigh) {
    maxHigh = CopySymb[i].high;
    iMaxHi = i;
  }

Print(iMaxHi, ": ", maxHigh);

And it's OK that ArrayMaximum doesn't work with MqlRates arrays.

 
Mihail Matkovskij #:

You could write it directly in the code:

but if you think about it?

even in this short code there are brutal mistakes

 
Maxim Kuznetsov #:

what if you think about it?

even in this short code there are brutal mistakes

Wrote the code online. Looked it over and fixed all the bugs I think. Paste the code into the script and the compiler will show the errors if there are any.

 
Mihail Matkovskij #:

Wrote the code online. Looked it over and fixed all the errors, I think. Insert code into script and compiler will show errors if there are any.

There is no cure with compiler, you just need to know: there may be 0 and EMPTY_VALUE in CopyXXX result. Very seldom but well. EMPTY_VALUE is DBL_MAX, i.e. the maximum value. That's what you'll find.

there is no check for correctness of values received from outside.

 
Maxim Kuznetsov #:

This can't be fixed with the compiler, you just need to know: CopyXXX results can contain both 0 and EMPTY_VALUE. Rarely but often. EMPTY_VALUE is DBL_MAX, i.e. the maximum value. That's what you'll find.

There is no check of correctness of values received from the outside.

Do you think CopyRates will return 0,EMPTY_VALUE orDBL_MAX in the array high? Are you serious? :)

Maybe you can show me an example where it happens?

 
Mihail Matkovskij #:

You think CopyRates will return 0,EMPTY_VALUE orDBL_MAX in an array high? Are you serious? :)

Maybe you can show me an example where it happens?

And what will ArrayMaximum do when it hits0,EMPTY_VALUE orDBL_MAX in array double filled with CopyHigh?

Where is the logic in your statement?

 
Mihail Matkovskij #:

You think CopyRates will return 0,EMPTY_VALUE orDBL_MAX in an array high? Are you serious? :)

Maybe you can show me an example where it happens?

I've made such mistakes. Start actively collecting statistics and you will.

ALWAYS check other people's data.

About the fact that even the Bid, Ask can be incorrect even in this thread said. I will not dig out the link, it's long, but it was and was cured

 
Hello! A customer found a bug in the software. I have fixed the code and put it in the new version of the software. Will the new version be available to the customer at no additional cost? How can I forward the corrected version to the customer?
 
Oleksandr Nozemtsev #:
Hello! A customer found a bug in the program. I fixed the code and uploaded it in the new version of the program. Will the new version be available to the buyer at no extra cost? How can I forward the corrected version to the buyer?

If you have just upgraded the product. Those who bought it will be able to upgrade without paying. If it's posted as a new product, of course it will only be available to those who buy/rent it.

 
Konstantin Nikitin #:

If you have just upgraded the product. Those who bought it will be able to upgrade without paying. If posted as a new product, of course only those who bought/rented it will be able to upgrade.

Posted in the same product in the tab "Versions" Was version 1.0, became 2.0. I.e. it should be free, as I understand it. Ok! How do I get the updates? Does the customer have to download and install the new version?

Reason: